diff options
author | ptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b> | 2016-09-28 00:51:09 +0000 |
---|---|---|
committer | ptmcg <ptmcg@9bf210a0-9d2d-494c-87cf-cfb32e7dff7b> | 2016-09-28 00:51:09 +0000 |
commit | 8a30afc12d6f3b93e56238ea791251bcccc87a82 (patch) | |
tree | 6ae1b98022a467a27496279b32a57a1d8cb6e0bd /src/unitTests.py | |
parent | 68c2b32b49f0c25d67b5a2e91ef0d1039f287e8b (diff) | |
download | pyparsing-8a30afc12d6f3b93e56238ea791251bcccc87a82.tar.gz |
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
Diffstat (limited to 'src/unitTests.py')
-rw-r--r-- | src/unitTests.py | 15 |
1 files changed, 15 insertions, 0 deletions
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
|