Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 06c0ec9

Browse files
committed
Several additions from Jeffrey.
1 parent 23b2257 commit 06c0ec9

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

Lib/test/re_tests.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@
272272
('(a)b(c)', 'abc', SUCCEED, 'found+"-"+g1+"-"+g2', 'abc-a-c'),
273273
('a+b+c', 'aabbabc', SUCCEED, 'found', 'abc'),
274274
('a{1,}b{1,}c', 'aabbabc', SUCCEED, 'found', 'abc'),
275-
#('a**', '-', SYNTAX_ERROR),
275+
('a**', '-', SYNTAX_ERROR),
276276
('a.+?c', 'abcabc', SUCCEED, 'found', 'abc'),
277277
('(a+|b)*', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'),
278278
('(a+|b){0,}', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'),
@@ -317,6 +317,7 @@
317317
# Python does not have the same rules for \\41 so this is a syntax error
318318
# ('((((((((((a))))))))))\\41', 'aa', FAIL),
319319
# ('((((((((((a))))))))))\\41', 'a!', SUCCEED, 'found', 'a!'),
320+
('((((((((((a))))))))))\\41', '', SYNTAX_ERROR),
320321
('(((((((((a)))))))))', 'a', SUCCEED, 'found', 'a'),
321322
('multiple words of text', 'uh-uh', FAIL),
322323
('multiple words', 'multiple words, yeah', SUCCEED, 'found', 'multiple words'),
@@ -400,7 +401,7 @@
400401
('(?i)(a)b(c)', 'ABC', SUCCEED, 'found+"-"+g1+"-"+g2', 'ABC-A-C'),
401402
('(?i)a+b+c', 'AABBABC', SUCCEED, 'found', 'ABC'),
402403
('(?i)a{1,}b{1,}c', 'AABBABC', SUCCEED, 'found', 'ABC'),
403-
#('(?i)a**', '-', SYNTAX_ERROR),
404+
('(?i)a**', '-', SYNTAX_ERROR),
404405
('(?i)a.+?c', 'ABCABC', SUCCEED, 'found', 'ABC'),
405406
('(?i)a.*?c', 'ABCABC', SUCCEED, 'found', 'ABC'),
406407
('(?i)a.{0,5}?c', 'ABCABC', SUCCEED, 'found', 'ABC'),
@@ -447,6 +448,7 @@
447448
('(?i)((((((((((a))))))))))\\10', 'AA', SUCCEED, 'found', 'AA'),
448449
#('(?i)((((((((((a))))))))))\\41', 'AA', FAIL),
449450
#('(?i)((((((((((a))))))))))\\41', 'A!', SUCCEED, 'found', 'A!'),
451+
('(?i)((((((((((a))))))))))\\41', '', SYNTAX_ERROR),
450452
('(?i)(((((((((a)))))))))', 'A', SUCCEED, 'found', 'A'),
451453
('(?i)(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))', 'A', SUCCEED, 'g1', 'A'),
452454
('(?i)(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))', 'C', SUCCEED, 'g1', 'C'),
@@ -474,11 +476,15 @@
474476

475477
('w(?# comment', 'w', SYNTAX_ERROR),
476478
('w(?# comment 1)xy(?# comment 2)z', 'wxyz', SUCCEED, 'found', 'wxyz'),
479+
480+
# Check odd placement of embedded pattern modifiers
481+
482+
('w(?i)', 'W', SYNTAX_ERROR),
477483

478-
# Comments using the x embedded pattern modifier (in an unusual place too)
484+
# Comments using the x embedded pattern modifier
479485

480-
("""w# comment 1
481-
x(?x) y
486+
("""(?x)w# comment 1
487+
x y
482488
# comment 2
483489
z""", 'wxyz', SUCCEED, 'found', 'wxyz'),
484490

@@ -491,8 +497,19 @@
491497
abc
492498
xyz""", SUCCEED, 'found', 'abc'),
493499

500+
('(?m)abc$', """jkl
501+
xyzabc
502+
123""", SUCCEED, 'found', 'abc'),
503+
494504
# using the s embedded pattern modifier
495505

496506
('a.b', 'a\nb', FAIL),
497507
('(?s)a.b', 'a\nb', SUCCEED, 'found', 'a\nb'),
508+
509+
# test \w, etc.
510+
511+
('\\w+', '--ab_cd0123--', SUCCEED, 'found', 'ab_cd0123'),
512+
('\\D+', '1234abc5678', SUCCEED, 'found', 'abc'),
513+
('[\\da-fA-F]+', '123abc', SUCCEED, 'found', '123abc'),
514+
('[\\d-x]', '-', SYNTAX_ERROR),
498515
]

0 commit comments

Comments
 (0)