1 | n/a | #!/usr/bin/env python3 |
---|
2 | n/a | # -*- mode: python -*- |
---|
3 | n/a | |
---|
4 | n/a | # Re test suite and benchmark suite v1.5 |
---|
5 | n/a | |
---|
6 | n/a | # The 3 possible outcomes for each pattern |
---|
7 | n/a | [SUCCEED, FAIL, SYNTAX_ERROR] = range(3) |
---|
8 | n/a | |
---|
9 | n/a | # Benchmark suite (needs expansion) |
---|
10 | n/a | # |
---|
11 | n/a | # The benchmark suite does not test correctness, just speed. The |
---|
12 | n/a | # first element of each tuple is the regex pattern; the second is a |
---|
13 | n/a | # string to match it against. The benchmarking code will embed the |
---|
14 | n/a | # second string inside several sizes of padding, to test how regex |
---|
15 | n/a | # matching performs on large strings. |
---|
16 | n/a | |
---|
17 | n/a | benchmarks = [ |
---|
18 | n/a | |
---|
19 | n/a | # test common prefix |
---|
20 | n/a | ('Python|Perl', 'Perl'), # Alternation |
---|
21 | n/a | ('(Python|Perl)', 'Perl'), # Grouped alternation |
---|
22 | n/a | |
---|
23 | n/a | ('Python|Perl|Tcl', 'Perl'), # Alternation |
---|
24 | n/a | ('(Python|Perl|Tcl)', 'Perl'), # Grouped alternation |
---|
25 | n/a | |
---|
26 | n/a | ('(Python)\\1', 'PythonPython'), # Backreference |
---|
27 | n/a | ('([0a-z][a-z0-9]*,)+', 'a5,b7,c9,'), # Disable the fastmap optimization |
---|
28 | n/a | ('([a-z][a-z0-9]*,)+', 'a5,b7,c9,'), # A few sets |
---|
29 | n/a | |
---|
30 | n/a | ('Python', 'Python'), # Simple text literal |
---|
31 | n/a | ('.*Python', 'Python'), # Bad text literal |
---|
32 | n/a | ('.*Python.*', 'Python'), # Worse text literal |
---|
33 | n/a | ('.*(Python)', 'Python'), # Bad text literal with grouping |
---|
34 | n/a | |
---|
35 | n/a | ] |
---|
36 | n/a | |
---|
37 | n/a | # Test suite (for verifying correctness) |
---|
38 | n/a | # |
---|
39 | n/a | # The test suite is a list of 5- or 3-tuples. The 5 parts of a |
---|
40 | n/a | # complete tuple are: |
---|
41 | n/a | # element 0: a string containing the pattern |
---|
42 | n/a | # 1: the string to match against the pattern |
---|
43 | n/a | # 2: the expected result (SUCCEED, FAIL, SYNTAX_ERROR) |
---|
44 | n/a | # 3: a string that will be eval()'ed to produce a test string. |
---|
45 | n/a | # This is an arbitrary Python expression; the available |
---|
46 | n/a | # variables are "found" (the whole match), and "g1", "g2", ... |
---|
47 | n/a | # up to "g99" contain the contents of each group, or the |
---|
48 | n/a | # string 'None' if the group wasn't given a value, or the |
---|
49 | n/a | # string 'Error' if the group index was out of range; |
---|
50 | n/a | # also "groups", the return value of m.group() (a tuple). |
---|
51 | n/a | # 4: The expected result of evaluating the expression. |
---|
52 | n/a | # If the two don't match, an error is reported. |
---|
53 | n/a | # |
---|
54 | n/a | # If the regex isn't expected to work, the latter two elements can be omitted. |
---|
55 | n/a | |
---|
56 | n/a | tests = [ |
---|
57 | n/a | # Test ?P< and ?P= extensions |
---|
58 | n/a | ('(?P<foo_123', '', SYNTAX_ERROR), # Unterminated group identifier |
---|
59 | n/a | ('(?P<1>a)', '', SYNTAX_ERROR), # Begins with a digit |
---|
60 | n/a | ('(?P<!>a)', '', SYNTAX_ERROR), # Begins with an illegal char |
---|
61 | n/a | ('(?P<foo!>a)', '', SYNTAX_ERROR), # Begins with an illegal char |
---|
62 | n/a | |
---|
63 | n/a | # Same tests, for the ?P= form |
---|
64 | n/a | ('(?P<foo_123>a)(?P=foo_123', 'aa', SYNTAX_ERROR), |
---|
65 | n/a | ('(?P<foo_123>a)(?P=1)', 'aa', SYNTAX_ERROR), |
---|
66 | n/a | ('(?P<foo_123>a)(?P=!)', 'aa', SYNTAX_ERROR), |
---|
67 | n/a | ('(?P<foo_123>a)(?P=foo_124', 'aa', SYNTAX_ERROR), # Backref to undefined group |
---|
68 | n/a | |
---|
69 | n/a | ('(?P<foo_123>a)', 'a', SUCCEED, 'g1', 'a'), |
---|
70 | n/a | ('(?P<foo_123>a)(?P=foo_123)', 'aa', SUCCEED, 'g1', 'a'), |
---|
71 | n/a | |
---|
72 | n/a | # Test octal escapes |
---|
73 | n/a | ('\\1', 'a', SYNTAX_ERROR), # Backreference |
---|
74 | n/a | ('[\\1]', '\1', SUCCEED, 'found', '\1'), # Character |
---|
75 | n/a | ('\\09', chr(0) + '9', SUCCEED, 'found', chr(0) + '9'), |
---|
76 | n/a | ('\\141', 'a', SUCCEED, 'found', 'a'), |
---|
77 | n/a | ('(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\\119', 'abcdefghijklk9', SUCCEED, 'found+"-"+g11', 'abcdefghijklk9-k'), |
---|
78 | n/a | |
---|
79 | n/a | # Test \0 is handled everywhere |
---|
80 | n/a | (r'\0', '\0', SUCCEED, 'found', '\0'), |
---|
81 | n/a | (r'[\0a]', '\0', SUCCEED, 'found', '\0'), |
---|
82 | n/a | (r'[a\0]', '\0', SUCCEED, 'found', '\0'), |
---|
83 | n/a | (r'[^a\0]', '\0', FAIL), |
---|
84 | n/a | |
---|
85 | n/a | # Test various letter escapes |
---|
86 | n/a | (r'\a[\b]\f\n\r\t\v', '\a\b\f\n\r\t\v', SUCCEED, 'found', '\a\b\f\n\r\t\v'), |
---|
87 | n/a | (r'[\a][\b][\f][\n][\r][\t][\v]', '\a\b\f\n\r\t\v', SUCCEED, 'found', '\a\b\f\n\r\t\v'), |
---|
88 | n/a | # NOTE: not an error under PCRE/PRE: |
---|
89 | n/a | (r'\u', '', SYNTAX_ERROR), # A Perl escape |
---|
90 | n/a | # (r'\c\e\g\h\i\j\k\m\o\p\q\y\z', 'ceghijkmopqyz', SUCCEED, 'found', 'ceghijkmopqyz'), |
---|
91 | n/a | (r'\xff', '\377', SUCCEED, 'found', chr(255)), |
---|
92 | n/a | # new \x semantics |
---|
93 | n/a | (r'\x00ffffffffffffff', '\377', FAIL, 'found', chr(255)), |
---|
94 | n/a | (r'\x00f', '\017', FAIL, 'found', chr(15)), |
---|
95 | n/a | (r'\x00fe', '\376', FAIL, 'found', chr(254)), |
---|
96 | n/a | # (r'\x00ffffffffffffff', '\377', SUCCEED, 'found', chr(255)), |
---|
97 | n/a | # (r'\x00f', '\017', SUCCEED, 'found', chr(15)), |
---|
98 | n/a | # (r'\x00fe', '\376', SUCCEED, 'found', chr(254)), |
---|
99 | n/a | |
---|
100 | n/a | (r"^\w+=(\\[\000-\277]|[^\n\\])*", "SRC=eval.c g.c blah blah blah \\\\\n\tapes.c", |
---|
101 | n/a | SUCCEED, 'found', "SRC=eval.c g.c blah blah blah \\\\"), |
---|
102 | n/a | |
---|
103 | n/a | # Test that . only matches \n in DOTALL mode |
---|
104 | n/a | ('a.b', 'acb', SUCCEED, 'found', 'acb'), |
---|
105 | n/a | ('a.b', 'a\nb', FAIL), |
---|
106 | n/a | ('a.*b', 'acc\nccb', FAIL), |
---|
107 | n/a | ('a.{4,5}b', 'acc\nccb', FAIL), |
---|
108 | n/a | ('a.b', 'a\rb', SUCCEED, 'found', 'a\rb'), |
---|
109 | n/a | ('(?s)a.b', 'a\nb', SUCCEED, 'found', 'a\nb'), |
---|
110 | n/a | ('(?s)a.*b', 'acc\nccb', SUCCEED, 'found', 'acc\nccb'), |
---|
111 | n/a | ('(?s)a.{4,5}b', 'acc\nccb', SUCCEED, 'found', 'acc\nccb'), |
---|
112 | n/a | ('(?s)a.b', 'a\nb', SUCCEED, 'found', 'a\nb'), |
---|
113 | n/a | |
---|
114 | n/a | (')', '', SYNTAX_ERROR), # Unmatched right bracket |
---|
115 | n/a | ('', '', SUCCEED, 'found', ''), # Empty pattern |
---|
116 | n/a | ('abc', 'abc', SUCCEED, 'found', 'abc'), |
---|
117 | n/a | ('abc', 'xbc', FAIL), |
---|
118 | n/a | ('abc', 'axc', FAIL), |
---|
119 | n/a | ('abc', 'abx', FAIL), |
---|
120 | n/a | ('abc', 'xabcy', SUCCEED, 'found', 'abc'), |
---|
121 | n/a | ('abc', 'ababc', SUCCEED, 'found', 'abc'), |
---|
122 | n/a | ('ab*c', 'abc', SUCCEED, 'found', 'abc'), |
---|
123 | n/a | ('ab*bc', 'abc', SUCCEED, 'found', 'abc'), |
---|
124 | n/a | ('ab*bc', 'abbc', SUCCEED, 'found', 'abbc'), |
---|
125 | n/a | ('ab*bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'), |
---|
126 | n/a | ('ab+bc', 'abbc', SUCCEED, 'found', 'abbc'), |
---|
127 | n/a | ('ab+bc', 'abc', FAIL), |
---|
128 | n/a | ('ab+bc', 'abq', FAIL), |
---|
129 | n/a | ('ab+bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'), |
---|
130 | n/a | ('ab?bc', 'abbc', SUCCEED, 'found', 'abbc'), |
---|
131 | n/a | ('ab?bc', 'abc', SUCCEED, 'found', 'abc'), |
---|
132 | n/a | ('ab?bc', 'abbbbc', FAIL), |
---|
133 | n/a | ('ab?c', 'abc', SUCCEED, 'found', 'abc'), |
---|
134 | n/a | ('^abc$', 'abc', SUCCEED, 'found', 'abc'), |
---|
135 | n/a | ('^abc$', 'abcc', FAIL), |
---|
136 | n/a | ('^abc', 'abcc', SUCCEED, 'found', 'abc'), |
---|
137 | n/a | ('^abc$', 'aabc', FAIL), |
---|
138 | n/a | ('abc$', 'aabc', SUCCEED, 'found', 'abc'), |
---|
139 | n/a | ('^', 'abc', SUCCEED, 'found+"-"', '-'), |
---|
140 | n/a | ('$', 'abc', SUCCEED, 'found+"-"', '-'), |
---|
141 | n/a | ('a.c', 'abc', SUCCEED, 'found', 'abc'), |
---|
142 | n/a | ('a.c', 'axc', SUCCEED, 'found', 'axc'), |
---|
143 | n/a | ('a.*c', 'axyzc', SUCCEED, 'found', 'axyzc'), |
---|
144 | n/a | ('a.*c', 'axyzd', FAIL), |
---|
145 | n/a | ('a[bc]d', 'abc', FAIL), |
---|
146 | n/a | ('a[bc]d', 'abd', SUCCEED, 'found', 'abd'), |
---|
147 | n/a | ('a[b-d]e', 'abd', FAIL), |
---|
148 | n/a | ('a[b-d]e', 'ace', SUCCEED, 'found', 'ace'), |
---|
149 | n/a | ('a[b-d]', 'aac', SUCCEED, 'found', 'ac'), |
---|
150 | n/a | ('a[-b]', 'a-', SUCCEED, 'found', 'a-'), |
---|
151 | n/a | ('a[\\-b]', 'a-', SUCCEED, 'found', 'a-'), |
---|
152 | n/a | # NOTE: not an error under PCRE/PRE: |
---|
153 | n/a | # ('a[b-]', 'a-', SYNTAX_ERROR), |
---|
154 | n/a | ('a[]b', '-', SYNTAX_ERROR), |
---|
155 | n/a | ('a[', '-', SYNTAX_ERROR), |
---|
156 | n/a | ('a\\', '-', SYNTAX_ERROR), |
---|
157 | n/a | ('abc)', '-', SYNTAX_ERROR), |
---|
158 | n/a | ('(abc', '-', SYNTAX_ERROR), |
---|
159 | n/a | ('a]', 'a]', SUCCEED, 'found', 'a]'), |
---|
160 | n/a | ('a[]]b', 'a]b', SUCCEED, 'found', 'a]b'), |
---|
161 | n/a | ('a[\\]]b', 'a]b', SUCCEED, 'found', 'a]b'), |
---|
162 | n/a | ('a[^bc]d', 'aed', SUCCEED, 'found', 'aed'), |
---|
163 | n/a | ('a[^bc]d', 'abd', FAIL), |
---|
164 | n/a | ('a[^-b]c', 'adc', SUCCEED, 'found', 'adc'), |
---|
165 | n/a | ('a[^-b]c', 'a-c', FAIL), |
---|
166 | n/a | ('a[^]b]c', 'a]c', FAIL), |
---|
167 | n/a | ('a[^]b]c', 'adc', SUCCEED, 'found', 'adc'), |
---|
168 | n/a | ('\\ba\\b', 'a-', SUCCEED, '"-"', '-'), |
---|
169 | n/a | ('\\ba\\b', '-a', SUCCEED, '"-"', '-'), |
---|
170 | n/a | ('\\ba\\b', '-a-', SUCCEED, '"-"', '-'), |
---|
171 | n/a | ('\\by\\b', 'xy', FAIL), |
---|
172 | n/a | ('\\by\\b', 'yz', FAIL), |
---|
173 | n/a | ('\\by\\b', 'xyz', FAIL), |
---|
174 | n/a | ('x\\b', 'xyz', FAIL), |
---|
175 | n/a | ('x\\B', 'xyz', SUCCEED, '"-"', '-'), |
---|
176 | n/a | ('\\Bz', 'xyz', SUCCEED, '"-"', '-'), |
---|
177 | n/a | ('z\\B', 'xyz', FAIL), |
---|
178 | n/a | ('\\Bx', 'xyz', FAIL), |
---|
179 | n/a | ('\\Ba\\B', 'a-', FAIL, '"-"', '-'), |
---|
180 | n/a | ('\\Ba\\B', '-a', FAIL, '"-"', '-'), |
---|
181 | n/a | ('\\Ba\\B', '-a-', FAIL, '"-"', '-'), |
---|
182 | n/a | ('\\By\\B', 'xy', FAIL), |
---|
183 | n/a | ('\\By\\B', 'yz', FAIL), |
---|
184 | n/a | ('\\By\\b', 'xy', SUCCEED, '"-"', '-'), |
---|
185 | n/a | ('\\by\\B', 'yz', SUCCEED, '"-"', '-'), |
---|
186 | n/a | ('\\By\\B', 'xyz', SUCCEED, '"-"', '-'), |
---|
187 | n/a | ('ab|cd', 'abc', SUCCEED, 'found', 'ab'), |
---|
188 | n/a | ('ab|cd', 'abcd', SUCCEED, 'found', 'ab'), |
---|
189 | n/a | ('()ef', 'def', SUCCEED, 'found+"-"+g1', 'ef-'), |
---|
190 | n/a | ('$b', 'b', FAIL), |
---|
191 | n/a | ('a\\(b', 'a(b', SUCCEED, 'found+"-"+g1', 'a(b-Error'), |
---|
192 | n/a | ('a\\(*b', 'ab', SUCCEED, 'found', 'ab'), |
---|
193 | n/a | ('a\\(*b', 'a((b', SUCCEED, 'found', 'a((b'), |
---|
194 | n/a | ('a\\\\b', 'a\\b', SUCCEED, 'found', 'a\\b'), |
---|
195 | n/a | ('((a))', 'abc', SUCCEED, 'found+"-"+g1+"-"+g2', 'a-a-a'), |
---|
196 | n/a | ('(a)b(c)', 'abc', SUCCEED, 'found+"-"+g1+"-"+g2', 'abc-a-c'), |
---|
197 | n/a | ('a+b+c', 'aabbabc', SUCCEED, 'found', 'abc'), |
---|
198 | n/a | ('(a+|b)*', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'), |
---|
199 | n/a | ('(a+|b)+', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'), |
---|
200 | n/a | ('(a+|b)?', 'ab', SUCCEED, 'found+"-"+g1', 'a-a'), |
---|
201 | n/a | (')(', '-', SYNTAX_ERROR), |
---|
202 | n/a | ('[^ab]*', 'cde', SUCCEED, 'found', 'cde'), |
---|
203 | n/a | ('abc', '', FAIL), |
---|
204 | n/a | ('a*', '', SUCCEED, 'found', ''), |
---|
205 | n/a | ('a|b|c|d|e', 'e', SUCCEED, 'found', 'e'), |
---|
206 | n/a | ('(a|b|c|d|e)f', 'ef', SUCCEED, 'found+"-"+g1', 'ef-e'), |
---|
207 | n/a | ('abcd*efg', 'abcdefg', SUCCEED, 'found', 'abcdefg'), |
---|
208 | n/a | ('ab*', 'xabyabbbz', SUCCEED, 'found', 'ab'), |
---|
209 | n/a | ('ab*', 'xayabbbz', SUCCEED, 'found', 'a'), |
---|
210 | n/a | ('(ab|cd)e', 'abcde', SUCCEED, 'found+"-"+g1', 'cde-cd'), |
---|
211 | n/a | ('[abhgefdc]ij', 'hij', SUCCEED, 'found', 'hij'), |
---|
212 | n/a | ('^(ab|cd)e', 'abcde', FAIL, 'xg1y', 'xy'), |
---|
213 | n/a | ('(abc|)ef', 'abcdef', SUCCEED, 'found+"-"+g1', 'ef-'), |
---|
214 | n/a | ('(a|b)c*d', 'abcd', SUCCEED, 'found+"-"+g1', 'bcd-b'), |
---|
215 | n/a | ('(ab|ab*)bc', 'abc', SUCCEED, 'found+"-"+g1', 'abc-a'), |
---|
216 | n/a | ('a([bc]*)c*', 'abc', SUCCEED, 'found+"-"+g1', 'abc-bc'), |
---|
217 | n/a | ('a([bc]*)(c*d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-bc-d'), |
---|
218 | n/a | ('a([bc]+)(c*d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-bc-d'), |
---|
219 | n/a | ('a([bc]*)(c+d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-b-cd'), |
---|
220 | n/a | ('a[bcd]*dcdcde', 'adcdcde', SUCCEED, 'found', 'adcdcde'), |
---|
221 | n/a | ('a[bcd]+dcdcde', 'adcdcde', FAIL), |
---|
222 | n/a | ('(ab|a)b*c', 'abc', SUCCEED, 'found+"-"+g1', 'abc-ab'), |
---|
223 | n/a | ('((a)(b)c)(d)', 'abcd', SUCCEED, 'g1+"-"+g2+"-"+g3+"-"+g4', 'abc-a-b-d'), |
---|
224 | n/a | ('[a-zA-Z_][a-zA-Z0-9_]*', 'alpha', SUCCEED, 'found', 'alpha'), |
---|
225 | n/a | ('^a(bc+|b[eh])g|.h$', 'abh', SUCCEED, 'found+"-"+g1', 'bh-None'), |
---|
226 | n/a | ('(bc+d$|ef*g.|h?i(j|k))', 'effgz', SUCCEED, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'), |
---|
227 | n/a | ('(bc+d$|ef*g.|h?i(j|k))', 'ij', SUCCEED, 'found+"-"+g1+"-"+g2', 'ij-ij-j'), |
---|
228 | n/a | ('(bc+d$|ef*g.|h?i(j|k))', 'effg', FAIL), |
---|
229 | n/a | ('(bc+d$|ef*g.|h?i(j|k))', 'bcdd', FAIL), |
---|
230 | n/a | ('(bc+d$|ef*g.|h?i(j|k))', 'reffgz', SUCCEED, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'), |
---|
231 | n/a | ('(((((((((a)))))))))', 'a', SUCCEED, 'found', 'a'), |
---|
232 | n/a | ('multiple words of text', 'uh-uh', FAIL), |
---|
233 | n/a | ('multiple words', 'multiple words, yeah', SUCCEED, 'found', 'multiple words'), |
---|
234 | n/a | ('(.*)c(.*)', 'abcde', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcde-ab-de'), |
---|
235 | n/a | ('\\((.*), (.*)\\)', '(a, b)', SUCCEED, 'g2+"-"+g1', 'b-a'), |
---|
236 | n/a | ('[k]', 'ab', FAIL), |
---|
237 | n/a | ('a[-]?c', 'ac', SUCCEED, 'found', 'ac'), |
---|
238 | n/a | ('(abc)\\1', 'abcabc', SUCCEED, 'g1', 'abc'), |
---|
239 | n/a | ('([a-c]*)\\1', 'abcabc', SUCCEED, 'g1', 'abc'), |
---|
240 | n/a | ('^(.+)?B', 'AB', SUCCEED, 'g1', 'A'), |
---|
241 | n/a | ('(a+).\\1$', 'aaaaa', SUCCEED, 'found+"-"+g1', 'aaaaa-aa'), |
---|
242 | n/a | ('^(a+).\\1$', 'aaaa', FAIL), |
---|
243 | n/a | ('(abc)\\1', 'abcabc', SUCCEED, 'found+"-"+g1', 'abcabc-abc'), |
---|
244 | n/a | ('([a-c]+)\\1', 'abcabc', SUCCEED, 'found+"-"+g1', 'abcabc-abc'), |
---|
245 | n/a | ('(a)\\1', 'aa', SUCCEED, 'found+"-"+g1', 'aa-a'), |
---|
246 | n/a | ('(a+)\\1', 'aa', SUCCEED, 'found+"-"+g1', 'aa-a'), |
---|
247 | n/a | ('(a+)+\\1', 'aa', SUCCEED, 'found+"-"+g1', 'aa-a'), |
---|
248 | n/a | ('(a).+\\1', 'aba', SUCCEED, 'found+"-"+g1', 'aba-a'), |
---|
249 | n/a | ('(a)ba*\\1', 'aba', SUCCEED, 'found+"-"+g1', 'aba-a'), |
---|
250 | n/a | ('(aa|a)a\\1$', 'aaa', SUCCEED, 'found+"-"+g1', 'aaa-a'), |
---|
251 | n/a | ('(a|aa)a\\1$', 'aaa', SUCCEED, 'found+"-"+g1', 'aaa-a'), |
---|
252 | n/a | ('(a+)a\\1$', 'aaa', SUCCEED, 'found+"-"+g1', 'aaa-a'), |
---|
253 | n/a | ('([abc]*)\\1', 'abcabc', SUCCEED, 'found+"-"+g1', 'abcabc-abc'), |
---|
254 | n/a | ('(a)(b)c|ab', 'ab', SUCCEED, 'found+"-"+g1+"-"+g2', 'ab-None-None'), |
---|
255 | n/a | ('(a)+x', 'aaax', SUCCEED, 'found+"-"+g1', 'aaax-a'), |
---|
256 | n/a | ('([ac])+x', 'aacx', SUCCEED, 'found+"-"+g1', 'aacx-c'), |
---|
257 | n/a | ('([^/]*/)*sub1/', 'd:msgs/tdir/sub1/trial/away.cpp', SUCCEED, 'found+"-"+g1', 'd:msgs/tdir/sub1/-tdir/'), |
---|
258 | n/a | ('([^.]*)\\.([^:]*):[T ]+(.*)', 'track1.title:TBlah blah blah', SUCCEED, 'found+"-"+g1+"-"+g2+"-"+g3', 'track1.title:TBlah blah blah-track1-title-Blah blah blah'), |
---|
259 | n/a | ('([^N]*N)+', 'abNNxyzN', SUCCEED, 'found+"-"+g1', 'abNNxyzN-xyzN'), |
---|
260 | n/a | ('([^N]*N)+', 'abNNxyz', SUCCEED, 'found+"-"+g1', 'abNN-N'), |
---|
261 | n/a | ('([abc]*)x', 'abcx', SUCCEED, 'found+"-"+g1', 'abcx-abc'), |
---|
262 | n/a | ('([abc]*)x', 'abc', FAIL), |
---|
263 | n/a | ('([xyz]*)x', 'abcx', SUCCEED, 'found+"-"+g1', 'x-'), |
---|
264 | n/a | ('(a)+b|aac', 'aac', SUCCEED, 'found+"-"+g1', 'aac-None'), |
---|
265 | n/a | |
---|
266 | n/a | # Test symbolic groups |
---|
267 | n/a | |
---|
268 | n/a | ('(?P<i d>aaa)a', 'aaaa', SYNTAX_ERROR), |
---|
269 | n/a | ('(?P<id>aaa)a', 'aaaa', SUCCEED, 'found+"-"+id', 'aaaa-aaa'), |
---|
270 | n/a | ('(?P<id>aa)(?P=id)', 'aaaa', SUCCEED, 'found+"-"+id', 'aaaa-aa'), |
---|
271 | n/a | ('(?P<id>aa)(?P=xd)', 'aaaa', SYNTAX_ERROR), |
---|
272 | n/a | |
---|
273 | n/a | # Test octal escapes/memory references |
---|
274 | n/a | |
---|
275 | n/a | ('\\1', 'a', SYNTAX_ERROR), |
---|
276 | n/a | ('\\09', chr(0) + '9', SUCCEED, 'found', chr(0) + '9'), |
---|
277 | n/a | ('\\141', 'a', SUCCEED, 'found', 'a'), |
---|
278 | n/a | ('(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)\\119', 'abcdefghijklk9', SUCCEED, 'found+"-"+g11', 'abcdefghijklk9-k'), |
---|
279 | n/a | |
---|
280 | n/a | # All tests from Perl |
---|
281 | n/a | |
---|
282 | n/a | ('abc', 'abc', SUCCEED, 'found', 'abc'), |
---|
283 | n/a | ('abc', 'xbc', FAIL), |
---|
284 | n/a | ('abc', 'axc', FAIL), |
---|
285 | n/a | ('abc', 'abx', FAIL), |
---|
286 | n/a | ('abc', 'xabcy', SUCCEED, 'found', 'abc'), |
---|
287 | n/a | ('abc', 'ababc', SUCCEED, 'found', 'abc'), |
---|
288 | n/a | ('ab*c', 'abc', SUCCEED, 'found', 'abc'), |
---|
289 | n/a | ('ab*bc', 'abc', SUCCEED, 'found', 'abc'), |
---|
290 | n/a | ('ab*bc', 'abbc', SUCCEED, 'found', 'abbc'), |
---|
291 | n/a | ('ab*bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'), |
---|
292 | n/a | ('ab{0,}bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'), |
---|
293 | n/a | ('ab+bc', 'abbc', SUCCEED, 'found', 'abbc'), |
---|
294 | n/a | ('ab+bc', 'abc', FAIL), |
---|
295 | n/a | ('ab+bc', 'abq', FAIL), |
---|
296 | n/a | ('ab{1,}bc', 'abq', FAIL), |
---|
297 | n/a | ('ab+bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'), |
---|
298 | n/a | ('ab{1,}bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'), |
---|
299 | n/a | ('ab{1,3}bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'), |
---|
300 | n/a | ('ab{3,4}bc', 'abbbbc', SUCCEED, 'found', 'abbbbc'), |
---|
301 | n/a | ('ab{4,5}bc', 'abbbbc', FAIL), |
---|
302 | n/a | ('ab?bc', 'abbc', SUCCEED, 'found', 'abbc'), |
---|
303 | n/a | ('ab?bc', 'abc', SUCCEED, 'found', 'abc'), |
---|
304 | n/a | ('ab{0,1}bc', 'abc', SUCCEED, 'found', 'abc'), |
---|
305 | n/a | ('ab?bc', 'abbbbc', FAIL), |
---|
306 | n/a | ('ab?c', 'abc', SUCCEED, 'found', 'abc'), |
---|
307 | n/a | ('ab{0,1}c', 'abc', SUCCEED, 'found', 'abc'), |
---|
308 | n/a | ('^abc$', 'abc', SUCCEED, 'found', 'abc'), |
---|
309 | n/a | ('^abc$', 'abcc', FAIL), |
---|
310 | n/a | ('^abc', 'abcc', SUCCEED, 'found', 'abc'), |
---|
311 | n/a | ('^abc$', 'aabc', FAIL), |
---|
312 | n/a | ('abc$', 'aabc', SUCCEED, 'found', 'abc'), |
---|
313 | n/a | ('^', 'abc', SUCCEED, 'found', ''), |
---|
314 | n/a | ('$', 'abc', SUCCEED, 'found', ''), |
---|
315 | n/a | ('a.c', 'abc', SUCCEED, 'found', 'abc'), |
---|
316 | n/a | ('a.c', 'axc', SUCCEED, 'found', 'axc'), |
---|
317 | n/a | ('a.*c', 'axyzc', SUCCEED, 'found', 'axyzc'), |
---|
318 | n/a | ('a.*c', 'axyzd', FAIL), |
---|
319 | n/a | ('a[bc]d', 'abc', FAIL), |
---|
320 | n/a | ('a[bc]d', 'abd', SUCCEED, 'found', 'abd'), |
---|
321 | n/a | ('a[b-d]e', 'abd', FAIL), |
---|
322 | n/a | ('a[b-d]e', 'ace', SUCCEED, 'found', 'ace'), |
---|
323 | n/a | ('a[b-d]', 'aac', SUCCEED, 'found', 'ac'), |
---|
324 | n/a | ('a[-b]', 'a-', SUCCEED, 'found', 'a-'), |
---|
325 | n/a | ('a[b-]', 'a-', SUCCEED, 'found', 'a-'), |
---|
326 | n/a | ('a[b-a]', '-', SYNTAX_ERROR), |
---|
327 | n/a | ('a[]b', '-', SYNTAX_ERROR), |
---|
328 | n/a | ('a[', '-', SYNTAX_ERROR), |
---|
329 | n/a | ('a]', 'a]', SUCCEED, 'found', 'a]'), |
---|
330 | n/a | ('a[]]b', 'a]b', SUCCEED, 'found', 'a]b'), |
---|
331 | n/a | ('a[^bc]d', 'aed', SUCCEED, 'found', 'aed'), |
---|
332 | n/a | ('a[^bc]d', 'abd', FAIL), |
---|
333 | n/a | ('a[^-b]c', 'adc', SUCCEED, 'found', 'adc'), |
---|
334 | n/a | ('a[^-b]c', 'a-c', FAIL), |
---|
335 | n/a | ('a[^]b]c', 'a]c', FAIL), |
---|
336 | n/a | ('a[^]b]c', 'adc', SUCCEED, 'found', 'adc'), |
---|
337 | n/a | ('ab|cd', 'abc', SUCCEED, 'found', 'ab'), |
---|
338 | n/a | ('ab|cd', 'abcd', SUCCEED, 'found', 'ab'), |
---|
339 | n/a | ('()ef', 'def', SUCCEED, 'found+"-"+g1', 'ef-'), |
---|
340 | n/a | ('*a', '-', SYNTAX_ERROR), |
---|
341 | n/a | ('(*)b', '-', SYNTAX_ERROR), |
---|
342 | n/a | ('$b', 'b', FAIL), |
---|
343 | n/a | ('a\\', '-', SYNTAX_ERROR), |
---|
344 | n/a | ('a\\(b', 'a(b', SUCCEED, 'found+"-"+g1', 'a(b-Error'), |
---|
345 | n/a | ('a\\(*b', 'ab', SUCCEED, 'found', 'ab'), |
---|
346 | n/a | ('a\\(*b', 'a((b', SUCCEED, 'found', 'a((b'), |
---|
347 | n/a | ('a\\\\b', 'a\\b', SUCCEED, 'found', 'a\\b'), |
---|
348 | n/a | ('abc)', '-', SYNTAX_ERROR), |
---|
349 | n/a | ('(abc', '-', SYNTAX_ERROR), |
---|
350 | n/a | ('((a))', 'abc', SUCCEED, 'found+"-"+g1+"-"+g2', 'a-a-a'), |
---|
351 | n/a | ('(a)b(c)', 'abc', SUCCEED, 'found+"-"+g1+"-"+g2', 'abc-a-c'), |
---|
352 | n/a | ('a+b+c', 'aabbabc', SUCCEED, 'found', 'abc'), |
---|
353 | n/a | ('a{1,}b{1,}c', 'aabbabc', SUCCEED, 'found', 'abc'), |
---|
354 | n/a | ('a**', '-', SYNTAX_ERROR), |
---|
355 | n/a | ('a.+?c', 'abcabc', SUCCEED, 'found', 'abc'), |
---|
356 | n/a | ('(a+|b)*', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'), |
---|
357 | n/a | ('(a+|b){0,}', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'), |
---|
358 | n/a | ('(a+|b)+', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'), |
---|
359 | n/a | ('(a+|b){1,}', 'ab', SUCCEED, 'found+"-"+g1', 'ab-b'), |
---|
360 | n/a | ('(a+|b)?', 'ab', SUCCEED, 'found+"-"+g1', 'a-a'), |
---|
361 | n/a | ('(a+|b){0,1}', 'ab', SUCCEED, 'found+"-"+g1', 'a-a'), |
---|
362 | n/a | (')(', '-', SYNTAX_ERROR), |
---|
363 | n/a | ('[^ab]*', 'cde', SUCCEED, 'found', 'cde'), |
---|
364 | n/a | ('abc', '', FAIL), |
---|
365 | n/a | ('a*', '', SUCCEED, 'found', ''), |
---|
366 | n/a | ('([abc])*d', 'abbbcd', SUCCEED, 'found+"-"+g1', 'abbbcd-c'), |
---|
367 | n/a | ('([abc])*bcd', 'abcd', SUCCEED, 'found+"-"+g1', 'abcd-a'), |
---|
368 | n/a | ('a|b|c|d|e', 'e', SUCCEED, 'found', 'e'), |
---|
369 | n/a | ('(a|b|c|d|e)f', 'ef', SUCCEED, 'found+"-"+g1', 'ef-e'), |
---|
370 | n/a | ('abcd*efg', 'abcdefg', SUCCEED, 'found', 'abcdefg'), |
---|
371 | n/a | ('ab*', 'xabyabbbz', SUCCEED, 'found', 'ab'), |
---|
372 | n/a | ('ab*', 'xayabbbz', SUCCEED, 'found', 'a'), |
---|
373 | n/a | ('(ab|cd)e', 'abcde', SUCCEED, 'found+"-"+g1', 'cde-cd'), |
---|
374 | n/a | ('[abhgefdc]ij', 'hij', SUCCEED, 'found', 'hij'), |
---|
375 | n/a | ('^(ab|cd)e', 'abcde', FAIL), |
---|
376 | n/a | ('(abc|)ef', 'abcdef', SUCCEED, 'found+"-"+g1', 'ef-'), |
---|
377 | n/a | ('(a|b)c*d', 'abcd', SUCCEED, 'found+"-"+g1', 'bcd-b'), |
---|
378 | n/a | ('(ab|ab*)bc', 'abc', SUCCEED, 'found+"-"+g1', 'abc-a'), |
---|
379 | n/a | ('a([bc]*)c*', 'abc', SUCCEED, 'found+"-"+g1', 'abc-bc'), |
---|
380 | n/a | ('a([bc]*)(c*d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-bc-d'), |
---|
381 | n/a | ('a([bc]+)(c*d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-bc-d'), |
---|
382 | n/a | ('a([bc]*)(c+d)', 'abcd', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcd-b-cd'), |
---|
383 | n/a | ('a[bcd]*dcdcde', 'adcdcde', SUCCEED, 'found', 'adcdcde'), |
---|
384 | n/a | ('a[bcd]+dcdcde', 'adcdcde', FAIL), |
---|
385 | n/a | ('(ab|a)b*c', 'abc', SUCCEED, 'found+"-"+g1', 'abc-ab'), |
---|
386 | n/a | ('((a)(b)c)(d)', 'abcd', SUCCEED, 'g1+"-"+g2+"-"+g3+"-"+g4', 'abc-a-b-d'), |
---|
387 | n/a | ('[a-zA-Z_][a-zA-Z0-9_]*', 'alpha', SUCCEED, 'found', 'alpha'), |
---|
388 | n/a | ('^a(bc+|b[eh])g|.h$', 'abh', SUCCEED, 'found+"-"+g1', 'bh-None'), |
---|
389 | n/a | ('(bc+d$|ef*g.|h?i(j|k))', 'effgz', SUCCEED, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'), |
---|
390 | n/a | ('(bc+d$|ef*g.|h?i(j|k))', 'ij', SUCCEED, 'found+"-"+g1+"-"+g2', 'ij-ij-j'), |
---|
391 | n/a | ('(bc+d$|ef*g.|h?i(j|k))', 'effg', FAIL), |
---|
392 | n/a | ('(bc+d$|ef*g.|h?i(j|k))', 'bcdd', FAIL), |
---|
393 | n/a | ('(bc+d$|ef*g.|h?i(j|k))', 'reffgz', SUCCEED, 'found+"-"+g1+"-"+g2', 'effgz-effgz-None'), |
---|
394 | n/a | ('((((((((((a))))))))))', 'a', SUCCEED, 'g10', 'a'), |
---|
395 | n/a | ('((((((((((a))))))))))\\10', 'aa', SUCCEED, 'found', 'aa'), |
---|
396 | n/a | # Python does not have the same rules for \\41 so this is a syntax error |
---|
397 | n/a | # ('((((((((((a))))))))))\\41', 'aa', FAIL), |
---|
398 | n/a | # ('((((((((((a))))))))))\\41', 'a!', SUCCEED, 'found', 'a!'), |
---|
399 | n/a | ('((((((((((a))))))))))\\41', '', SYNTAX_ERROR), |
---|
400 | n/a | ('(?i)((((((((((a))))))))))\\41', '', SYNTAX_ERROR), |
---|
401 | n/a | ('(((((((((a)))))))))', 'a', SUCCEED, 'found', 'a'), |
---|
402 | n/a | ('multiple words of text', 'uh-uh', FAIL), |
---|
403 | n/a | ('multiple words', 'multiple words, yeah', SUCCEED, 'found', 'multiple words'), |
---|
404 | n/a | ('(.*)c(.*)', 'abcde', SUCCEED, 'found+"-"+g1+"-"+g2', 'abcde-ab-de'), |
---|
405 | n/a | ('\\((.*), (.*)\\)', '(a, b)', SUCCEED, 'g2+"-"+g1', 'b-a'), |
---|
406 | n/a | ('[k]', 'ab', FAIL), |
---|
407 | n/a | ('a[-]?c', 'ac', SUCCEED, 'found', 'ac'), |
---|
408 | n/a | ('(abc)\\1', 'abcabc', SUCCEED, 'g1', 'abc'), |
---|
409 | n/a | ('([a-c]*)\\1', 'abcabc', SUCCEED, 'g1', 'abc'), |
---|
410 | n/a | ('(?i)abc', 'ABC', SUCCEED, 'found', 'ABC'), |
---|
411 | n/a | ('(?i)abc', 'XBC', FAIL), |
---|
412 | n/a | ('(?i)abc', 'AXC', FAIL), |
---|
413 | n/a | ('(?i)abc', 'ABX', FAIL), |
---|
414 | n/a | ('(?i)abc', 'XABCY', SUCCEED, 'found', 'ABC'), |
---|
415 | n/a | ('(?i)abc', 'ABABC', SUCCEED, 'found', 'ABC'), |
---|
416 | n/a | ('(?i)ab*c', 'ABC', SUCCEED, 'found', 'ABC'), |
---|
417 | n/a | ('(?i)ab*bc', 'ABC', SUCCEED, 'found', 'ABC'), |
---|
418 | n/a | ('(?i)ab*bc', 'ABBC', SUCCEED, 'found', 'ABBC'), |
---|
419 | n/a | ('(?i)ab*?bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'), |
---|
420 | n/a | ('(?i)ab{0,}?bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'), |
---|
421 | n/a | ('(?i)ab+?bc', 'ABBC', SUCCEED, 'found', 'ABBC'), |
---|
422 | n/a | ('(?i)ab+bc', 'ABC', FAIL), |
---|
423 | n/a | ('(?i)ab+bc', 'ABQ', FAIL), |
---|
424 | n/a | ('(?i)ab{1,}bc', 'ABQ', FAIL), |
---|
425 | n/a | ('(?i)ab+bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'), |
---|
426 | n/a | ('(?i)ab{1,}?bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'), |
---|
427 | n/a | ('(?i)ab{1,3}?bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'), |
---|
428 | n/a | ('(?i)ab{3,4}?bc', 'ABBBBC', SUCCEED, 'found', 'ABBBBC'), |
---|
429 | n/a | ('(?i)ab{4,5}?bc', 'ABBBBC', FAIL), |
---|
430 | n/a | ('(?i)ab??bc', 'ABBC', SUCCEED, 'found', 'ABBC'), |
---|
431 | n/a | ('(?i)ab??bc', 'ABC', SUCCEED, 'found', 'ABC'), |
---|
432 | n/a | ('(?i)ab{0,1}?bc', 'ABC', SUCCEED, 'found', 'ABC'), |
---|
433 | n/a | ('(?i)ab??bc', 'ABBBBC', FAIL), |
---|
434 | n/a | ('(?i)ab??c', 'ABC', SUCCEED, 'found', 'ABC'), |
---|
435 | n/a | ('(?i)ab{0,1}?c', 'ABC', SUCCEED, 'found', 'ABC'), |
---|
436 | n/a | ('(?i)^abc$', 'ABC', SUCCEED, 'found', 'ABC'), |
---|
437 | n/a | ('(?i)^abc$', 'ABCC', FAIL), |
---|
438 | n/a | ('(?i)^abc', 'ABCC', SUCCEED, 'found', 'ABC'), |
---|
439 | n/a | ('(?i)^abc$', 'AABC', FAIL), |
---|
440 | n/a | ('(?i)abc$', 'AABC', SUCCEED, 'found', 'ABC'), |
---|
441 | n/a | ('(?i)^', 'ABC', SUCCEED, 'found', ''), |
---|
442 | n/a | ('(?i)$', 'ABC', SUCCEED, 'found', ''), |
---|
443 | n/a | ('(?i)a.c', 'ABC', SUCCEED, 'found', 'ABC'), |
---|
444 | n/a | ('(?i)a.c', 'AXC', SUCCEED, 'found', 'AXC'), |
---|
445 | n/a | ('(?i)a.*?c', 'AXYZC', SUCCEED, 'found', 'AXYZC'), |
---|
446 | n/a | ('(?i)a.*c', 'AXYZD', FAIL), |
---|
447 | n/a | ('(?i)a[bc]d', 'ABC', FAIL), |
---|
448 | n/a | ('(?i)a[bc]d', 'ABD', SUCCEED, 'found', 'ABD'), |
---|
449 | n/a | ('(?i)a[b-d]e', 'ABD', FAIL), |
---|
450 | n/a | ('(?i)a[b-d]e', 'ACE', SUCCEED, 'found', 'ACE'), |
---|
451 | n/a | ('(?i)a[b-d]', 'AAC', SUCCEED, 'found', 'AC'), |
---|
452 | n/a | ('(?i)a[-b]', 'A-', SUCCEED, 'found', 'A-'), |
---|
453 | n/a | ('(?i)a[b-]', 'A-', SUCCEED, 'found', 'A-'), |
---|
454 | n/a | ('(?i)a[b-a]', '-', SYNTAX_ERROR), |
---|
455 | n/a | ('(?i)a[]b', '-', SYNTAX_ERROR), |
---|
456 | n/a | ('(?i)a[', '-', SYNTAX_ERROR), |
---|
457 | n/a | ('(?i)a]', 'A]', SUCCEED, 'found', 'A]'), |
---|
458 | n/a | ('(?i)a[]]b', 'A]B', SUCCEED, 'found', 'A]B'), |
---|
459 | n/a | ('(?i)a[^bc]d', 'AED', SUCCEED, 'found', 'AED'), |
---|
460 | n/a | ('(?i)a[^bc]d', 'ABD', FAIL), |
---|
461 | n/a | ('(?i)a[^-b]c', 'ADC', SUCCEED, 'found', 'ADC'), |
---|
462 | n/a | ('(?i)a[^-b]c', 'A-C', FAIL), |
---|
463 | n/a | ('(?i)a[^]b]c', 'A]C', FAIL), |
---|
464 | n/a | ('(?i)a[^]b]c', 'ADC', SUCCEED, 'found', 'ADC'), |
---|
465 | n/a | ('(?i)ab|cd', 'ABC', SUCCEED, 'found', 'AB'), |
---|
466 | n/a | ('(?i)ab|cd', 'ABCD', SUCCEED, 'found', 'AB'), |
---|
467 | n/a | ('(?i)()ef', 'DEF', SUCCEED, 'found+"-"+g1', 'EF-'), |
---|
468 | n/a | ('(?i)*a', '-', SYNTAX_ERROR), |
---|
469 | n/a | ('(?i)(*)b', '-', SYNTAX_ERROR), |
---|
470 | n/a | ('(?i)$b', 'B', FAIL), |
---|
471 | n/a | ('(?i)a\\', '-', SYNTAX_ERROR), |
---|
472 | n/a | ('(?i)a\\(b', 'A(B', SUCCEED, 'found+"-"+g1', 'A(B-Error'), |
---|
473 | n/a | ('(?i)a\\(*b', 'AB', SUCCEED, 'found', 'AB'), |
---|
474 | n/a | ('(?i)a\\(*b', 'A((B', SUCCEED, 'found', 'A((B'), |
---|
475 | n/a | ('(?i)a\\\\b', 'A\\B', SUCCEED, 'found', 'A\\B'), |
---|
476 | n/a | ('(?i)abc)', '-', SYNTAX_ERROR), |
---|
477 | n/a | ('(?i)(abc', '-', SYNTAX_ERROR), |
---|
478 | n/a | ('(?i)((a))', 'ABC', SUCCEED, 'found+"-"+g1+"-"+g2', 'A-A-A'), |
---|
479 | n/a | ('(?i)(a)b(c)', 'ABC', SUCCEED, 'found+"-"+g1+"-"+g2', 'ABC-A-C'), |
---|
480 | n/a | ('(?i)a+b+c', 'AABBABC', SUCCEED, 'found', 'ABC'), |
---|
481 | n/a | ('(?i)a{1,}b{1,}c', 'AABBABC', SUCCEED, 'found', 'ABC'), |
---|
482 | n/a | ('(?i)a**', '-', SYNTAX_ERROR), |
---|
483 | n/a | ('(?i)a.+?c', 'ABCABC', SUCCEED, 'found', 'ABC'), |
---|
484 | n/a | ('(?i)a.*?c', 'ABCABC', SUCCEED, 'found', 'ABC'), |
---|
485 | n/a | ('(?i)a.{0,5}?c', 'ABCABC', SUCCEED, 'found', 'ABC'), |
---|
486 | n/a | ('(?i)(a+|b)*', 'AB', SUCCEED, 'found+"-"+g1', 'AB-B'), |
---|
487 | n/a | ('(?i)(a+|b){0,}', 'AB', SUCCEED, 'found+"-"+g1', 'AB-B'), |
---|
488 | n/a | ('(?i)(a+|b)+', 'AB', SUCCEED, 'found+"-"+g1', 'AB-B'), |
---|
489 | n/a | ('(?i)(a+|b){1,}', 'AB', SUCCEED, 'found+"-"+g1', 'AB-B'), |
---|
490 | n/a | ('(?i)(a+|b)?', 'AB', SUCCEED, 'found+"-"+g1', 'A-A'), |
---|
491 | n/a | ('(?i)(a+|b){0,1}', 'AB', SUCCEED, 'found+"-"+g1', 'A-A'), |
---|
492 | n/a | ('(?i)(a+|b){0,1}?', 'AB', SUCCEED, 'found+"-"+g1', '-None'), |
---|
493 | n/a | ('(?i))(', '-', SYNTAX_ERROR), |
---|
494 | n/a | ('(?i)[^ab]*', 'CDE', SUCCEED, 'found', 'CDE'), |
---|
495 | n/a | ('(?i)abc', '', FAIL), |
---|
496 | n/a | ('(?i)a*', '', SUCCEED, 'found', ''), |
---|
497 | n/a | ('(?i)([abc])*d', 'ABBBCD', SUCCEED, 'found+"-"+g1', 'ABBBCD-C'), |
---|
498 | n/a | ('(?i)([abc])*bcd', 'ABCD', SUCCEED, 'found+"-"+g1', 'ABCD-A'), |
---|
499 | n/a | ('(?i)a|b|c|d|e', 'E', SUCCEED, 'found', 'E'), |
---|
500 | n/a | ('(?i)(a|b|c|d|e)f', 'EF', SUCCEED, 'found+"-"+g1', 'EF-E'), |
---|
501 | n/a | ('(?i)abcd*efg', 'ABCDEFG', SUCCEED, 'found', 'ABCDEFG'), |
---|
502 | n/a | ('(?i)ab*', 'XABYABBBZ', SUCCEED, 'found', 'AB'), |
---|
503 | n/a | ('(?i)ab*', 'XAYABBBZ', SUCCEED, 'found', 'A'), |
---|
504 | n/a | ('(?i)(ab|cd)e', 'ABCDE', SUCCEED, 'found+"-"+g1', 'CDE-CD'), |
---|
505 | n/a | ('(?i)[abhgefdc]ij', 'HIJ', SUCCEED, 'found', 'HIJ'), |
---|
506 | n/a | ('(?i)^(ab|cd)e', 'ABCDE', FAIL), |
---|
507 | n/a | ('(?i)(abc|)ef', 'ABCDEF', SUCCEED, 'found+"-"+g1', 'EF-'), |
---|
508 | n/a | ('(?i)(a|b)c*d', 'ABCD', SUCCEED, 'found+"-"+g1', 'BCD-B'), |
---|
509 | n/a | ('(?i)(ab|ab*)bc', 'ABC', SUCCEED, 'found+"-"+g1', 'ABC-A'), |
---|
510 | n/a | ('(?i)a([bc]*)c*', 'ABC', SUCCEED, 'found+"-"+g1', 'ABC-BC'), |
---|
511 | n/a | ('(?i)a([bc]*)(c*d)', 'ABCD', SUCCEED, 'found+"-"+g1+"-"+g2', 'ABCD-BC-D'), |
---|
512 | n/a | ('(?i)a([bc]+)(c*d)', 'ABCD', SUCCEED, 'found+"-"+g1+"-"+g2', 'ABCD-BC-D'), |
---|
513 | n/a | ('(?i)a([bc]*)(c+d)', 'ABCD', SUCCEED, 'found+"-"+g1+"-"+g2', 'ABCD-B-CD'), |
---|
514 | n/a | ('(?i)a[bcd]*dcdcde', 'ADCDCDE', SUCCEED, 'found', 'ADCDCDE'), |
---|
515 | n/a | ('(?i)a[bcd]+dcdcde', 'ADCDCDE', FAIL), |
---|
516 | n/a | ('(?i)(ab|a)b*c', 'ABC', SUCCEED, 'found+"-"+g1', 'ABC-AB'), |
---|
517 | n/a | ('(?i)((a)(b)c)(d)', 'ABCD', SUCCEED, 'g1+"-"+g2+"-"+g3+"-"+g4', 'ABC-A-B-D'), |
---|
518 | n/a | ('(?i)[a-zA-Z_][a-zA-Z0-9_]*', 'ALPHA', SUCCEED, 'found', 'ALPHA'), |
---|
519 | n/a | ('(?i)^a(bc+|b[eh])g|.h$', 'ABH', SUCCEED, 'found+"-"+g1', 'BH-None'), |
---|
520 | n/a | ('(?i)(bc+d$|ef*g.|h?i(j|k))', 'EFFGZ', SUCCEED, 'found+"-"+g1+"-"+g2', 'EFFGZ-EFFGZ-None'), |
---|
521 | n/a | ('(?i)(bc+d$|ef*g.|h?i(j|k))', 'IJ', SUCCEED, 'found+"-"+g1+"-"+g2', 'IJ-IJ-J'), |
---|
522 | n/a | ('(?i)(bc+d$|ef*g.|h?i(j|k))', 'EFFG', FAIL), |
---|
523 | n/a | ('(?i)(bc+d$|ef*g.|h?i(j|k))', 'BCDD', FAIL), |
---|
524 | n/a | ('(?i)(bc+d$|ef*g.|h?i(j|k))', 'REFFGZ', SUCCEED, 'found+"-"+g1+"-"+g2', 'EFFGZ-EFFGZ-None'), |
---|
525 | n/a | ('(?i)((((((((((a))))))))))', 'A', SUCCEED, 'g10', 'A'), |
---|
526 | n/a | ('(?i)((((((((((a))))))))))\\10', 'AA', SUCCEED, 'found', 'AA'), |
---|
527 | n/a | #('(?i)((((((((((a))))))))))\\41', 'AA', FAIL), |
---|
528 | n/a | #('(?i)((((((((((a))))))))))\\41', 'A!', SUCCEED, 'found', 'A!'), |
---|
529 | n/a | ('(?i)(((((((((a)))))))))', 'A', SUCCEED, 'found', 'A'), |
---|
530 | n/a | ('(?i)(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))', 'A', SUCCEED, 'g1', 'A'), |
---|
531 | n/a | ('(?i)(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))', 'C', SUCCEED, 'g1', 'C'), |
---|
532 | n/a | ('(?i)multiple words of text', 'UH-UH', FAIL), |
---|
533 | n/a | ('(?i)multiple words', 'MULTIPLE WORDS, YEAH', SUCCEED, 'found', 'MULTIPLE WORDS'), |
---|
534 | n/a | ('(?i)(.*)c(.*)', 'ABCDE', SUCCEED, 'found+"-"+g1+"-"+g2', 'ABCDE-AB-DE'), |
---|
535 | n/a | ('(?i)\\((.*), (.*)\\)', '(A, B)', SUCCEED, 'g2+"-"+g1', 'B-A'), |
---|
536 | n/a | ('(?i)[k]', 'AB', FAIL), |
---|
537 | n/a | # ('(?i)abcd', 'ABCD', SUCCEED, 'found+"-"+\\found+"-"+\\\\found', 'ABCD-$&-\\ABCD'), |
---|
538 | n/a | # ('(?i)a(bc)d', 'ABCD', SUCCEED, 'g1+"-"+\\g1+"-"+\\\\g1', 'BC-$1-\\BC'), |
---|
539 | n/a | ('(?i)a[-]?c', 'AC', SUCCEED, 'found', 'AC'), |
---|
540 | n/a | ('(?i)(abc)\\1', 'ABCABC', SUCCEED, 'g1', 'ABC'), |
---|
541 | n/a | ('(?i)([a-c]*)\\1', 'ABCABC', SUCCEED, 'g1', 'ABC'), |
---|
542 | n/a | ('a(?!b).', 'abad', SUCCEED, 'found', 'ad'), |
---|
543 | n/a | ('a(?=d).', 'abad', SUCCEED, 'found', 'ad'), |
---|
544 | n/a | ('a(?=c|d).', 'abad', SUCCEED, 'found', 'ad'), |
---|
545 | n/a | ('a(?:b|c|d)(.)', 'ace', SUCCEED, 'g1', 'e'), |
---|
546 | n/a | ('a(?:b|c|d)*(.)', 'ace', SUCCEED, 'g1', 'e'), |
---|
547 | n/a | ('a(?:b|c|d)+?(.)', 'ace', SUCCEED, 'g1', 'e'), |
---|
548 | n/a | ('a(?:b|(c|e){1,2}?|d)+?(.)', 'ace', SUCCEED, 'g1 + g2', 'ce'), |
---|
549 | n/a | ('^(.+)?B', 'AB', SUCCEED, 'g1', 'A'), |
---|
550 | n/a | |
---|
551 | n/a | # lookbehind: split by : but not if it is escaped by -. |
---|
552 | n/a | ('(?<!-):(.*?)(?<!-):', 'a:bc-:de:f', SUCCEED, 'g1', 'bc-:de' ), |
---|
553 | n/a | # escaping with \ as we know it |
---|
554 | n/a | ('(?<!\\\\):(.*?)(?<!\\\\):', 'a:bc\\:de:f', SUCCEED, 'g1', 'bc\\:de' ), |
---|
555 | n/a | # terminating with ' and escaping with ? as in edifact |
---|
556 | n/a | ("(?<!\\?)'(.*?)(?<!\\?)'", "a'bc?'de'f", SUCCEED, 'g1', "bc?'de" ), |
---|
557 | n/a | |
---|
558 | n/a | # Comments using the (?#...) syntax |
---|
559 | n/a | |
---|
560 | n/a | ('w(?# comment', 'w', SYNTAX_ERROR), |
---|
561 | n/a | ('w(?# comment 1)xy(?# comment 2)z', 'wxyz', SUCCEED, 'found', 'wxyz'), |
---|
562 | n/a | |
---|
563 | n/a | # Check odd placement of embedded pattern modifiers |
---|
564 | n/a | |
---|
565 | n/a | # not an error under PCRE/PRE: |
---|
566 | n/a | ('(?i)w', 'W', SUCCEED, 'found', 'W'), |
---|
567 | n/a | # ('w(?i)', 'W', SYNTAX_ERROR), |
---|
568 | n/a | |
---|
569 | n/a | # Comments using the x embedded pattern modifier |
---|
570 | n/a | |
---|
571 | n/a | ("""(?x)w# comment 1 |
---|
572 | n/a | x y |
---|
573 | n/a | # comment 2 |
---|
574 | n/a | z""", 'wxyz', SUCCEED, 'found', 'wxyz'), |
---|
575 | n/a | |
---|
576 | n/a | # using the m embedded pattern modifier |
---|
577 | n/a | |
---|
578 | n/a | ('^abc', """jkl |
---|
579 | n/a | abc |
---|
580 | n/a | xyz""", FAIL), |
---|
581 | n/a | ('(?m)^abc', """jkl |
---|
582 | n/a | abc |
---|
583 | n/a | xyz""", SUCCEED, 'found', 'abc'), |
---|
584 | n/a | |
---|
585 | n/a | ('(?m)abc$', """jkl |
---|
586 | n/a | xyzabc |
---|
587 | n/a | 123""", SUCCEED, 'found', 'abc'), |
---|
588 | n/a | |
---|
589 | n/a | # using the s embedded pattern modifier |
---|
590 | n/a | |
---|
591 | n/a | ('a.b', 'a\nb', FAIL), |
---|
592 | n/a | ('(?s)a.b', 'a\nb', SUCCEED, 'found', 'a\nb'), |
---|
593 | n/a | |
---|
594 | n/a | # test \w, etc. both inside and outside character classes |
---|
595 | n/a | |
---|
596 | n/a | ('\\w+', '--ab_cd0123--', SUCCEED, 'found', 'ab_cd0123'), |
---|
597 | n/a | ('[\\w]+', '--ab_cd0123--', SUCCEED, 'found', 'ab_cd0123'), |
---|
598 | n/a | ('\\D+', '1234abc5678', SUCCEED, 'found', 'abc'), |
---|
599 | n/a | ('[\\D]+', '1234abc5678', SUCCEED, 'found', 'abc'), |
---|
600 | n/a | ('[\\da-fA-F]+', '123abc', SUCCEED, 'found', '123abc'), |
---|
601 | n/a | # not an error under PCRE/PRE: |
---|
602 | n/a | # ('[\\d-x]', '-', SYNTAX_ERROR), |
---|
603 | n/a | (r'([\s]*)([\S]*)([\s]*)', ' testing!1972', SUCCEED, 'g3+g2+g1', 'testing!1972 '), |
---|
604 | n/a | (r'(\s*)(\S*)(\s*)', ' testing!1972', SUCCEED, 'g3+g2+g1', 'testing!1972 '), |
---|
605 | n/a | |
---|
606 | n/a | (r'\xff', '\377', SUCCEED, 'found', chr(255)), |
---|
607 | n/a | # new \x semantics |
---|
608 | n/a | (r'\x00ff', '\377', FAIL), |
---|
609 | n/a | # (r'\x00ff', '\377', SUCCEED, 'found', chr(255)), |
---|
610 | n/a | (r'\t\n\v\r\f\a', '\t\n\v\r\f\a', SUCCEED, 'found', '\t\n\v\r\f\a'), |
---|
611 | n/a | ('\t\n\v\r\f\a', '\t\n\v\r\f\a', SUCCEED, 'found', '\t\n\v\r\f\a'), |
---|
612 | n/a | (r'\t\n\v\r\f\a', '\t\n\v\r\f\a', SUCCEED, 'found', chr(9)+chr(10)+chr(11)+chr(13)+chr(12)+chr(7)), |
---|
613 | n/a | (r'[\t][\n][\v][\r][\f][\b]', '\t\n\v\r\f\b', SUCCEED, 'found', '\t\n\v\r\f\b'), |
---|
614 | n/a | |
---|
615 | n/a | # |
---|
616 | n/a | # post-1.5.2 additions |
---|
617 | n/a | |
---|
618 | n/a | # xmllib problem |
---|
619 | n/a | (r'(([a-z]+):)?([a-z]+)$', 'smil', SUCCEED, 'g1+"-"+g2+"-"+g3', 'None-None-smil'), |
---|
620 | n/a | # bug 110866: reference to undefined group |
---|
621 | n/a | (r'((.)\1+)', '', SYNTAX_ERROR), |
---|
622 | n/a | # bug 111869: search (PRE/PCRE fails on this one, SRE doesn't) |
---|
623 | n/a | (r'.*d', 'abc\nabd', SUCCEED, 'found', 'abd'), |
---|
624 | n/a | # bug 112468: various expected syntax errors |
---|
625 | n/a | (r'(', '', SYNTAX_ERROR), |
---|
626 | n/a | (r'[\41]', '!', SUCCEED, 'found', '!'), |
---|
627 | n/a | # bug 114033: nothing to repeat |
---|
628 | n/a | (r'(x?)?', 'x', SUCCEED, 'found', 'x'), |
---|
629 | n/a | # bug 115040: rescan if flags are modified inside pattern |
---|
630 | n/a | (r'(?x) foo ', 'foo', SUCCEED, 'found', 'foo'), |
---|
631 | n/a | # bug 115618: negative lookahead |
---|
632 | n/a | (r'(?<!abc)(d.f)', 'abcdefdof', SUCCEED, 'found', 'dof'), |
---|
633 | n/a | # bug 116251: character class bug |
---|
634 | n/a | (r'[\w-]+', 'laser_beam', SUCCEED, 'found', 'laser_beam'), |
---|
635 | n/a | # bug 123769+127259: non-greedy backtracking bug |
---|
636 | n/a | (r'.*?\S *:', 'xx:', SUCCEED, 'found', 'xx:'), |
---|
637 | n/a | (r'a[ ]*?\ (\d+).*', 'a 10', SUCCEED, 'found', 'a 10'), |
---|
638 | n/a | (r'a[ ]*?\ (\d+).*', 'a 10', SUCCEED, 'found', 'a 10'), |
---|
639 | n/a | # bug 127259: \Z shouldn't depend on multiline mode |
---|
640 | n/a | (r'(?ms).*?x\s*\Z(.*)','xx\nx\n', SUCCEED, 'g1', ''), |
---|
641 | n/a | # bug 128899: uppercase literals under the ignorecase flag |
---|
642 | n/a | (r'(?i)M+', 'MMM', SUCCEED, 'found', 'MMM'), |
---|
643 | n/a | (r'(?i)m+', 'MMM', SUCCEED, 'found', 'MMM'), |
---|
644 | n/a | (r'(?i)[M]+', 'MMM', SUCCEED, 'found', 'MMM'), |
---|
645 | n/a | (r'(?i)[m]+', 'MMM', SUCCEED, 'found', 'MMM'), |
---|
646 | n/a | # bug 130748: ^* should be an error (nothing to repeat) |
---|
647 | n/a | (r'^*', '', SYNTAX_ERROR), |
---|
648 | n/a | # bug 133283: minimizing repeat problem |
---|
649 | n/a | (r'"(?:\\"|[^"])*?"', r'"\""', SUCCEED, 'found', r'"\""'), |
---|
650 | n/a | # bug 477728: minimizing repeat problem |
---|
651 | n/a | (r'^.*?$', 'one\ntwo\nthree\n', FAIL), |
---|
652 | n/a | # bug 483789: minimizing repeat problem |
---|
653 | n/a | (r'a[^>]*?b', 'a>b', FAIL), |
---|
654 | n/a | # bug 490573: minimizing repeat problem |
---|
655 | n/a | (r'^a*?$', 'foo', FAIL), |
---|
656 | n/a | # bug 470582: nested groups problem |
---|
657 | n/a | (r'^((a)c)?(ab)$', 'ab', SUCCEED, 'g1+"-"+g2+"-"+g3', 'None-None-ab'), |
---|
658 | n/a | # another minimizing repeat problem (capturing groups in assertions) |
---|
659 | n/a | ('^([ab]*?)(?=(b)?)c', 'abc', SUCCEED, 'g1+"-"+g2', 'ab-None'), |
---|
660 | n/a | ('^([ab]*?)(?!(b))c', 'abc', SUCCEED, 'g1+"-"+g2', 'ab-None'), |
---|
661 | n/a | ('^([ab]*?)(?<!(a))c', 'abc', SUCCEED, 'g1+"-"+g2', 'ab-None'), |
---|
662 | n/a | ] |
---|
663 | n/a | |
---|
664 | n/a | u = '\N{LATIN CAPITAL LETTER A WITH DIAERESIS}' |
---|
665 | n/a | tests.extend([ |
---|
666 | n/a | # bug 410271: \b broken under locales |
---|
667 | n/a | (r'\b.\b', 'a', SUCCEED, 'found', 'a'), |
---|
668 | n/a | (r'(?u)\b.\b', u, SUCCEED, 'found', u), |
---|
669 | n/a | (r'(?u)\w', u, SUCCEED, 'found', u), |
---|
670 | n/a | ]) |
---|