diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2019-08-04 23:11:07 -0500 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2019-08-04 23:11:07 -0500 |
commit | 897e536d2131c6d07cbc355edb0ed744213c6997 (patch) | |
tree | 4454dd53ac5b874779605b1b2f82a144913215e7 /unitTests.py | |
parent | b0f76d82a134d2ea2324b384ac9eba6c50a516d3 (diff) | |
download | pyparsing-git-897e536d2131c6d07cbc355edb0ed744213c6997.tar.gz |
Improved handling of '-' ErrorStop's when used within Each
Diffstat (limited to 'unitTests.py')
-rw-r--r-- | unitTests.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/unitTests.py b/unitTests.py index 330afe1..999f2c7 100644 --- a/unitTests.py +++ b/unitTests.py @@ -2909,6 +2909,31 @@ class OptionalEachTest(ParseTestCase): self.runTest3() self.runTest4() +class EachWithParseFatalExceptionTest(ParseTestCase): + def runTest(self): + import pyparsing as pp + ppc = pp.pyparsing_common + + option_expr = pp.Keyword('options') - '(' + ppc.integer + ')' + step_expr1 = pp.Keyword('step') - '(' + ppc.integer + ")" + step_expr2 = pp.Keyword('step') - '(' + ppc.integer + "Z" + ")" + step_expr = step_expr1 ^ step_expr2 + + parser = option_expr & step_expr[...] + tests = [ + ("options(100) step(A)", "Expected integer, found 'A' (at char 18), (line:1, col:19)"), + ("step(A) options(100)", "Expected integer, found 'A' (at char 5), (line:1, col:6)"), + ("options(100) step(100A)", """Expected "Z", found 'A' (at char 21), (line:1, col:22)"""), + ("options(100) step(22) step(100ZA)", + """Expected ")", found 'A' (at char 31), (line:1, col:32)"""), + ] + test_lookup = dict(tests) + + success, output = parser.runTests((t[0] for t in tests), failureTests=True) + for test_str, result in output: + self.assertEqual(test_lookup[test_str], str(result), + "incorrect exception raised for test string {0!r}".format(test_str)) + class SumParseResultsTest(ParseTestCase): def runTest(self): |