From 8a30afc12d6f3b93e56238ea791251bcccc87a82 Mon Sep 17 00:00:00 2001 From: ptmcg Date: Wed, 28 Sep 2016 00:51:09 +0000 Subject: Fix bug in ZeroOrMore results name reporting git-svn-id: svn://svn.code.sf.net/p/pyparsing/code/trunk@444 9bf210a0-9d2d-494c-87cf-cfb32e7dff7b --- src/unitTests.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/unitTests.py') diff --git a/src/unitTests.py b/src/unitTests.py index d9a6471..8eaade5 100644 --- a/src/unitTests.py +++ b/src/unitTests.py @@ -3403,6 +3403,7 @@ class MiscellaneousParserTests(ParseTestCase): # test bugfix with repeated tokens when packrat parsing enabled if "L" in runtests: + print_('verify behavior with repeated tokens when packrat parsing is enabled') a = pyparsing.Literal("a") b = pyparsing.Literal("b") c = pyparsing.Literal("c") @@ -3413,6 +3414,20 @@ class MiscellaneousParserTests(ParseTestCase): grammar = abb | abc | aba assert ''.join(grammar.parseString( "aba" )) == 'aba', "Packrat ABA failure!" + + if "M" in runtests: + print_('verify behavior of setResultsName with OneOrMore and ZeroOrMore') + + stmt = pyparsing.Keyword('test') + print(pyparsing.ZeroOrMore(stmt)('tests').parseString('test test').tests) + print(pyparsing.OneOrMore(stmt)('tests').parseString('test test').tests) + print(pyparsing.Optional(pyparsing.OneOrMore(stmt)('tests')).parseString('test test').tests) + print(pyparsing.Optional(pyparsing.OneOrMore(stmt))('tests').parseString('test test').tests) + assert False, "testing..." + assert len(pyparsing.ZeroOrMore(stmt)('tests').parseString('test test').tests) == 2, "ZeroOrMore failure with setResultsName" + assert len(pyparsing.OneOrMore(stmt)('tests').parseString('test test').tests) == 2, "OneOrMore failure with setResultsName" + assert len(pyparsing.Optional(pyparsing.OneOrMore(stmt)('tests')).parseString('test test').tests) == 2, "OneOrMore failure with setResultsName" + assert len(pyparsing.Optional(pyparsing.OneOrMore(stmt))('tests').parseString('test test').tests) == 2, "OneOrMore failure with setResultsName" def makeTestSuite(): import inspect -- cgit v1.2.1