ยปCore Development>Code coverage>Lib/test/re_tests.py

Python code coverage for Lib/test/re_tests.py

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