|
3 | 3 |
|
4 | 4 |
|
5 | 5 | def test_single_character_class(): |
6 | | - regexEnumerator = RegexEnumerator(r'[a]') |
| 6 | + regex = r'[a]' |
7 | 7 | possibilities = ['a'] |
8 | 8 |
|
9 | | - f_finite(regexEnumerator, possibilities) |
| 9 | + f_finite(regex, possibilities) |
10 | 10 |
|
11 | 11 |
|
12 | 12 | def test_character_class_with_two_literals(): |
13 | | - regexEnumerator = RegexEnumerator(r'[ab]') |
| 13 | + regex = r'[ab]' |
14 | 14 | possibilities = ['a', 'b'] |
15 | 15 |
|
16 | | - f_finite(regexEnumerator, possibilities) |
| 16 | + f_finite(regex, possibilities) |
17 | 17 |
|
18 | 18 |
|
19 | 19 | def test_character_class_with_zero_or_more_quantifier(): |
20 | | - regexEnumerator = RegexEnumerator(r'[a]*') |
| 20 | + regex = r'[a]*' |
21 | 21 | possibilities = ['', 'a', 'aa', 'aaa', 'aaaa', 'aaaaa'] |
22 | 22 |
|
23 | | - f_infinite(regexEnumerator, possibilities) |
| 23 | + f_infinite(regex, possibilities) |
24 | 24 |
|
25 | 25 |
|
26 | 26 | def test_range_character_class(): |
27 | | - regexEnumerator = RegexEnumerator(r'[a-c]') |
| 27 | + regex = r'[a-c]' |
28 | 28 | possibilities = ['a', 'b', 'c'] |
29 | 29 |
|
30 | | - f_finite(regexEnumerator, possibilities) |
| 30 | + f_finite(regex, possibilities) |
31 | 31 |
|
32 | 32 |
|
33 | 33 | def test_range_character_class_with_repetition(): |
34 | | - regexEnumerator = RegexEnumerator(r'[a-c]{1,2}') |
| 34 | + regex = r'[a-c]{1,2}' |
35 | 35 | possibilities = ['a', 'b', 'c', 'aa', 'ab', |
36 | 36 | 'ac', 'ba', 'bb', 'bc', 'ca', 'cb', 'cc'] |
37 | 37 |
|
38 | | - f_finite(regexEnumerator, possibilities) |
| 38 | + f_finite(regex, possibilities) |
39 | 39 |
|
40 | 40 |
|
41 | 41 | def test_range_character_class_with_zero_repetition(): |
42 | | - regexEnumerator = RegexEnumerator(r'[a-c]{0}') |
| 42 | + regex = r'[a-c]{0}' |
43 | 43 | possibilities = [''] |
44 | 44 |
|
45 | | - f_finite(regexEnumerator, possibilities) |
| 45 | + f_finite(regex, possibilities) |
46 | 46 |
|
47 | 47 |
|
48 | 48 | def test_range_character_class_with_one_or_more_quantifier(): |
49 | | - regexEnumerator = RegexEnumerator(r'[a-b]+') |
| 49 | + regex = r'[a-b]+' |
50 | 50 | possibilities = ['a', 'b', 'aa', 'ab', 'ba', 'bb', 'aaa', |
51 | 51 | 'aab', 'aba', 'abb', 'baa', 'bab', 'bba', 'bbb'] |
52 | 52 |
|
53 | | - f_infinite(regexEnumerator, possibilities) |
| 53 | + f_infinite(regex, possibilities) |
54 | 54 |
|
55 | 55 |
|
56 | 56 | def test_two_ranges_with_optional_quantifier(): |
57 | | - regexEnumerator = RegexEnumerator(r'[a-cf-g]?') |
| 57 | + regex = r'[a-cf-g]?' |
58 | 58 | possibilities = ['', 'a', 'b', 'c', 'f', 'g'] |
59 | 59 |
|
60 | | - f_finite(regexEnumerator, possibilities) |
| 60 | + f_finite(regex, possibilities) |
61 | 61 |
|
62 | 62 |
|
63 | 63 | def test_literal_in_character_class(): |
64 | | - regexEnumerator = RegexEnumerator(r'[.]') |
| 64 | + regex = r'[.]' |
65 | 65 | possibilities = ['.'] |
66 | 66 |
|
67 | | - f_finite(regexEnumerator, possibilities) |
| 67 | + f_finite(regex, possibilities) |
68 | 68 |
|
69 | 69 |
|
70 | 70 | def test_negated_character_class(): |
71 | | - regexEnumerator = RegexEnumerator(r'[^a]') |
| 71 | + regex = r'[^a]' |
72 | 72 | possibilities = [chr(i) for i in range(32, 127) if chr(i) != 'a'] |
73 | 73 |
|
74 | | - f_finite(regexEnumerator, possibilities) |
| 74 | + f_finite(regex, possibilities) |
75 | 75 |
|
76 | 76 |
|
77 | 77 | def test_character_class_with_escaped_special_char_at_start(): |
78 | | - regexEnumerator = RegexEnumerator(r'[\]-a]') |
| 78 | + regex = r'[\]-a]' |
79 | 79 | possibilities = [chr(i) for i in range(93, 98)] |
80 | 80 |
|
81 | | - f_finite(regexEnumerator, possibilities) |
| 81 | + f_finite(regex, possibilities) |
82 | 82 |
|
83 | 83 |
|
84 | 84 | def test_character_class_with_escaped_special_char_at_end(): |
85 | | - regexEnumerator = RegexEnumerator(r'[Z-\]]') |
| 85 | + regex = r'[Z-\]]' |
86 | 86 | possibilities = [chr(i) for i in range(90, 94)] |
87 | 87 |
|
88 | | - f_finite(regexEnumerator, possibilities) |
| 88 | + f_finite(regex, possibilities) |
89 | 89 |
|
90 | 90 |
|
91 | 91 | def test_character_class_with_escape_sequence(): |
92 | | - regexEnumerator = RegexEnumerator(r'[\d]') |
| 92 | + regex = r'[\d]' |
93 | 93 | possibilities = [str(i) for i in range(10)] |
94 | 94 |
|
95 | | - f_finite(regexEnumerator, possibilities) |
| 95 | + f_finite(regex, possibilities) |
96 | 96 |
|
97 | 97 |
|
98 | 98 | def test_incomplete_range_character_class(): |
99 | | - regexEnumerator = RegexEnumerator(r'[a-]') |
| 99 | + regex = r'[a-]' |
100 | 100 | possibilities = ['a', '-'] |
101 | 101 |
|
102 | | - f_finite(regexEnumerator, possibilities) |
| 102 | + f_finite(regex, possibilities) |
103 | 103 |
|
104 | 104 |
|
105 | 105 | def test_2_ranges(): |
106 | | - regexEnumerator = RegexEnumerator(r'[1a-crf-g3]') |
| 106 | + regex = r'[1a-crf-g3]' |
107 | 107 | possibilities = ['1', 'a', 'b', 'c', 'f', 'g', 'r', '3'] |
108 | 108 |
|
109 | | - f_finite(regexEnumerator, possibilities) |
| 109 | + f_finite(regex, possibilities) |
110 | 110 |
|
111 | 111 |
|
112 | 112 | def test_unicode_character_class(): |
113 | | - regexEnumerator = RegexEnumerator(r'[à-å]') |
| 113 | + regex = r'[à-å]' |
114 | 114 | possibilities = ['à', 'á', 'â', 'ã', 'ä', 'å'] |
115 | 115 |
|
116 | | - f_finite(regexEnumerator, possibilities) |
| 116 | + f_finite(regex, possibilities) |
117 | 117 |
|
118 | 118 |
|
119 | 119 | def test_additional_charset(): |
120 | | - regexEnumerator = RegexEnumerator( |
121 | | - r'[^\w\d\s]', additional_charset=['γ', 'β', 'α']) |
| 120 | + regex = r'[^\w\d\s]' |
| 121 | + additional_charset = ['γ', 'β', 'α'] |
122 | 122 | possibilities = ['!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', ':', |
123 | 123 | ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '`', '{', '|', '}', '~', 'α', 'β', 'γ'] |
124 | 124 |
|
125 | | - f_finite(regexEnumerator, possibilities) |
| 125 | + f_finite(regex, possibilities, additional_charset) |
| 126 | + |
126 | 127 |
|
127 | 128 | def test_charclass_with_quantifier_from_0(): |
128 | | - regexEnumerator = RegexEnumerator(r'[b-d]{0,2}') |
129 | | - possibilities = ['', 'b', 'c', 'd', 'bb', 'bc', 'bd', 'cb', 'cc', 'cd', 'db', 'dc', 'dd'] |
| 129 | + regex = r'[b-d]{0,2}' |
| 130 | + possibilities = ['', 'b', 'c', 'd', 'bb', 'bc', |
| 131 | + 'bd', 'cb', 'cc', 'cd', 'db', 'dc', 'dd'] |
130 | 132 |
|
131 | | - f_finite(regexEnumerator, set(possibilities)) |
| 133 | + f_finite(regex, set(possibilities)) |
0 commit comments