summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_re.py
diff options
context:
space:
mode:
authorGustavo Niemeyer <gustavo@niemeyer.net>2003-10-17 22:13:16 (GMT)
committerGustavo Niemeyer <gustavo@niemeyer.net>2003-10-17 22:13:16 (GMT)
commitad3fc44ccb40f2ad33c0d09f5a2dfbd4feb442eb (patch)
tree929ea71dea18a5ee0c5c862bbb39d37b693209ad /Lib/test/test_re.py
parent41e2809febd6e09a34adf21beb6d2ae2360fdc46 (diff)
downloadcpython-ad3fc44ccb40f2ad33c0d09f5a2dfbd4feb442eb.zip
cpython-ad3fc44ccb40f2ad33c0d09f5a2dfbd4feb442eb.tar.gz
cpython-ad3fc44ccb40f2ad33c0d09f5a2dfbd4feb442eb.tar.bz2
Implemented non-recursive SRE matching.
Diffstat (limited to 'Lib/test/test_re.py')
-rw-r--r--Lib/test/test_re.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index f724806..d2e2753 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -169,7 +169,6 @@ class ReTests(unittest.TestCase):
self.assertEqual(pat.match('ac').group(1, 'b2', 3), ('a', None, 'c'))
def test_re_groupref_exists(self):
- return # not yet
self.assertEqual(re.match('^(\()?([^()]+)(?(1)\))$', '(a)').groups(),
('(', 'a'))
self.assertEqual(re.match('^(\()?([^()]+)(?(1)\))$', 'a').groups(),
@@ -405,19 +404,20 @@ class ReTests(unittest.TestCase):
self.assertEqual(re.match('.*?cd', 5000*'ab'+'c'+5000*'ab'+'cde').end(0),
20003)
self.assertEqual(re.match('.*?cd', 20000*'abc'+'de').end(0), 60001)
- # non-simple '*?' still recurses and hits the recursion limit
- self.assertRaises(RuntimeError, re.search, '(a|b)*?c', 10000*'ab'+'cd')
+ # non-simple '*?' still used to hit the recursion limit, before the
+ # non-recursive scheme was implemented.
+ self.assertEqual(re.search('(a|b)*?c', 10000*'ab'+'cd').end(0), 20001)
def test_bug_612074(self):
pat=u"["+re.escape(u"\u2039")+u"]"
self.assertEqual(re.compile(pat) and 1, 1)
def test_stack_overflow(self):
- # nasty case that overflows the straightforward recursive
+ # nasty cases that used to overflow the straightforward recursive
# implementation of repeated groups.
- self.assertRaises(RuntimeError, re.match, '(x)*', 50000*'x')
- self.assertRaises(RuntimeError, re.match, '(x)*y', 50000*'x'+'y')
- self.assertRaises(RuntimeError, re.match, '(x)*?y', 50000*'x'+'y')
+ self.assertEqual(re.match('(x)*', 50000*'x').group(1), 'x')
+ self.assertEqual(re.match('(x)*y', 50000*'x'+'y').group(1), 'x')
+ self.assertEqual(re.match('(x)*?y', 50000*'x'+'y').group(1), 'x')
def test_scanner(self):
def s_ident(scanner, token): return token