summaryrefslogtreecommitdiff
path: root/unitTests.py
diff options
context:
space:
mode:
authorPaul McGuire <ptmcg@austin.rr.com>2019-10-13 00:29:58 -0500
committerPaul McGuire <ptmcg@austin.rr.com>2019-10-13 00:29:58 -0500
commit417332636f38ff6afb966fa63c2f8fe341ca6b4d (patch)
treecacd9e9d2a9adf3c9e16c259789d12dc4495e567 /unitTests.py
parent6ee198cf78bee62d602fbd8c9e7c7144be3fd3f2 (diff)
downloadpyparsing-git-417332636f38ff6afb966fa63c2f8fe341ca6b4d.tar.gz
Fix PrecededBy bug, issue #127
Diffstat (limited to 'unitTests.py')
-rw-r--r--unitTests.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/unitTests.py b/unitTests.py
index 3bddbf4..7f516b1 100644
--- a/unitTests.py
+++ b/unitTests.py
@@ -2069,11 +2069,28 @@ class PrecededByTest(ParseTestCase):
(finicky_num, [2939], {}),
(very_boring_num, [404], {}),
]:
- print(expr.searchString(s))
+ # print(expr.searchString(s))
result = sum(expr.searchString(s))
print(result.dump())
self.assertParseResultsEquals(result, expected_list, expected_dict)
+ # infinite loop test - from Issue #127
+ string_test = 'notworking'
+ # negs = pp.Or(['not', 'un'])('negs')
+ negs_pb = pp.PrecededBy('not', retreat=100)('negs_lb')
+ # negs_pb = pp.PrecededBy(negs, retreat=100)('negs_lb')
+ pattern = (negs_pb + pp.Literal('working'))('main')
+
+ results = pattern.searchString(string_test)
+ try:
+ print(results.dump())
+ except RecursionError:
+ self.assertTrue(False, "got maximum excursion limit exception")
+ else:
+ self.assertTrue(True, "got maximum excursion limit exception")
+
+
+
class CountedArrayTest(ParseTestCase):
def runTest(self):
from pyparsing import Word, nums, OneOrMore, countedArray