Skip to content

Commit 96be025

Browse files
committed
9. add unit-tests
1 parent 1560a0c commit 96be025

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Lib/test/test_re.py

+24
Original file line numberDiff line numberDiff line change
@@ -1646,6 +1646,9 @@ def test_dealloc(self):
16461646
_sre.compile("abc", 0, [long_overflow], 0, {}, (), 0)
16471647
with self.assertRaises(TypeError):
16481648
_sre.compile({}, 0, [], 0, [], [], 0)
1649+
with self.assertRaises(RuntimeError):
1650+
# invalid repeat_count -1
1651+
_sre.compile("abc", 0, [1], 0, {}, (), -1)
16491652

16501653
def test_search_dot_unicode(self):
16511654
self.assertTrue(re.search("123.*-", '123abc-'))
@@ -2334,6 +2337,27 @@ def test_possesive_repeat(self):
23342337
14. SUCCESS
23352338
''')
23362339

2340+
def test_repeat_index(self):
2341+
self.assertEqual(get_debug_out(r'(?:ab)*(?:cd)*'), '''\
2342+
MAX_REPEAT 0 MAXREPEAT
2343+
LITERAL 97
2344+
LITERAL 98
2345+
MAX_REPEAT 0 MAXREPEAT
2346+
LITERAL 99
2347+
LITERAL 100
2348+
2349+
0. INFO 4 0b0 0 MAXREPEAT (to 5)
2350+
5: REPEAT 8 0 MAXREPEAT 0 (to 14)
2351+
10. LITERAL 0x61 ('a')
2352+
12. LITERAL 0x62 ('b')
2353+
14: MAX_UNTIL
2354+
15. REPEAT 8 0 MAXREPEAT 1 (to 24)
2355+
20. LITERAL 0x63 ('c')
2356+
22. LITERAL 0x64 ('d')
2357+
24: MAX_UNTIL
2358+
25. SUCCESS
2359+
''')
2360+
23372361

23382362
class PatternReprTests(unittest.TestCase):
23392363
def check(self, pattern, expected):

0 commit comments

Comments
 (0)