diff options
author | ptmcg <ptmcg@austin.rr.com> | 2020-01-04 17:43:44 -0600 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2020-01-04 17:43:44 -0600 |
commit | 062778c428a75c5b966f14bf91619c4e328261ab (patch) | |
tree | ebe5846a986fd015e5facbc76dd87db23504bc87 /tests/test_unit.py | |
parent | 95c5de2b0b7c04009e0f8d02f9533e59f1b16d1d (diff) | |
download | pyparsing-git-062778c428a75c5b966f14bf91619c4e328261ab.tar.gz |
Rollforward infixNotation ternary op fix from 2.4.6 branch, plus related unit test; change TestParseResultsAsserts to mixin instead of subclass; rollforward 2.4.6 CHANGES blurb from 2.4.6 branch
Diffstat (limited to 'tests/test_unit.py')
-rw-r--r-- | tests/test_unit.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/test_unit.py b/tests/test_unit.py index 070a9d1..b643262 100644 --- a/tests/test_unit.py +++ b/tests/test_unit.py @@ -19,7 +19,6 @@ from pyparsing import ParserElement from tests.json_parser_tests import test1, test2, test3, test4, test5 ppt = pp.pyparsing_test -TestParseResultsAsserts = ppt.TestParseResultsAsserts # see which Python implementation we are running CPYTHON_ENV = sys.platform == "win32" @@ -81,7 +80,7 @@ class Test1_PyparsingTestInit(TestCase): print("Python version", sys.version) -class Test2_WithoutPackrat(TestParseResultsAsserts): +class Test2_WithoutPackrat(ppt.TestParseResultsAsserts, TestCase): suite_context = None def setUp(self): @@ -6359,6 +6358,21 @@ class Test2_WithoutPackrat(TestParseResultsAsserts): ) print() + def testChainedTernaryOperator(self): + TERNARY_INFIX = pp.infixNotation( + pp.pyparsing_common.integer, [(("?", ":"), 3, pp.opAssoc.LEFT),] + ) + self.assertParseAndCheckList( + TERNARY_INFIX, "1?1:0?1:0", [[1, "?", 1, ":", 0, "?", 1, ":", 0]] + ) + + TERNARY_INFIX = pp.infixNotation( + pp.pyparsing_common.integer, [(("?", ":"), 3, pp.opAssoc.RIGHT),] + ) + self.assertParseAndCheckList( + TERNARY_INFIX, "1?1:0?1:0", [[1, "?", 1, ":", [0, "?", 1, ":", 0]]] + ) + def testMiscellaneousParserTests(self): runtests = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |