diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2019-08-09 06:46:56 -0500 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2019-08-09 06:46:56 -0500 |
commit | 7c1db54c6b4de188d7bebcc7372b926a13fd3da4 (patch) | |
tree | e224eaeef31b55a4bcf6a672733ec13dc95d7836 /unitTests.py | |
parent | c02db7427de3197d607e30ba42031884802a6f94 (diff) | |
download | pyparsing-git-7c1db54c6b4de188d7bebcc7372b926a13fd3da4.tar.gz |
Fixed bug in indentedBlock with a parser using two different types of nested indented blocks with different indent values, but sharing the same indent stack. Raised in comments on #87.
Diffstat (limited to 'unitTests.py')
-rw-r--r-- | unitTests.py | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/unitTests.py b/unitTests.py index 9fe246e..8601be1 100644 --- a/unitTests.py +++ b/unitTests.py @@ -4217,12 +4217,12 @@ class IndentedBlockTest2(ParseTestCase): key.setParseAction(key_parse_action) header = Suppress("[") + Literal("test") + Suppress("]") - content = (header + OneOrMore(indentedBlock(body, indent_stack, False))) + content = (header - OneOrMore(indentedBlock(body, indent_stack, False))) contents = Forward() suites = indentedBlock(content, indent_stack) - extra = Literal("extra") + Suppress(":") + suites + extra = Literal("extra") + Suppress(":") - suites contents << (content | extra) parser = OneOrMore(contents) @@ -4245,6 +4245,41 @@ class IndentedBlockTest2(ParseTestCase): success, _ = parser.runTests([sample]) self.assertTrue(success, "Failed indentedBlock test for issue #87") + sample2 = dedent(""" + extra: + [test] + one: + two (three) + four: + five (seven) + extra: + [test] + one: + two (three) + four: + five (seven) + + [test] + one: + two (three) + four: + five (seven) + + [test] + eight: + nine (ten) + eleven: + twelve (thirteen) + + fourteen: + fifteen (sixteen) + seventeen: + eighteen (nineteen) + """) + + del indent_stack[1:] + success, _ = parser.runTests([sample2]) + self.assertTrue(success, "Failed indentedBlock multi-block test for issue #87") class IndentedBlockScanTest(ParseTestCase): def get_parser(self): |