regexp_parser 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -1
- data/Gemfile +1 -1
- data/README.md +9 -13
- data/lib/regexp_parser/expression.rb +33 -21
- data/lib/regexp_parser/expression/classes/backref.rb +18 -10
- data/lib/regexp_parser/expression/classes/conditional.rb +4 -0
- data/lib/regexp_parser/expression/classes/group.rb +4 -2
- data/lib/regexp_parser/expression/classes/keep.rb +1 -3
- data/lib/regexp_parser/expression/methods/match_length.rb +172 -0
- data/lib/regexp_parser/expression/quantifier.rb +2 -2
- data/lib/regexp_parser/expression/sequence.rb +0 -4
- data/lib/regexp_parser/expression/subexpression.rb +3 -5
- data/lib/regexp_parser/lexer.rb +31 -24
- data/lib/regexp_parser/parser.rb +25 -3
- data/lib/regexp_parser/syntax/tokens.rb +2 -10
- data/lib/regexp_parser/version.rb +1 -1
- data/regexp_parser.gemspec +2 -2
- data/spec/expression/base_spec.rb +80 -0
- data/spec/expression/clone_spec.rb +120 -0
- data/spec/expression/conditional_spec.rb +89 -0
- data/spec/expression/free_space_spec.rb +27 -0
- data/spec/expression/methods/match_length_spec.rb +141 -0
- data/spec/expression/methods/strfregexp_spec.rb +224 -0
- data/spec/expression/methods/tests_spec.rb +97 -0
- data/spec/expression/methods/traverse_spec.rb +140 -0
- data/spec/expression/subexpression_spec.rb +50 -0
- data/spec/expression/to_h_spec.rb +26 -0
- data/spec/expression/to_s_spec.rb +100 -0
- data/spec/lexer/all_spec.rb +22 -0
- data/{test/lexer/test_conditionals.rb → spec/lexer/conditionals_spec.rb} +31 -35
- data/spec/lexer/escapes_spec.rb +38 -0
- data/spec/lexer/keep_spec.rb +22 -0
- data/{test/lexer/test_literals.rb → spec/lexer/literals_spec.rb} +20 -24
- data/{test/lexer/test_nesting.rb → spec/lexer/nesting_spec.rb} +11 -13
- data/spec/lexer/refcalls_spec.rb +54 -0
- data/spec/parser/all_spec.rb +31 -0
- data/spec/parser/alternation_spec.rb +88 -0
- data/{test/parser/test_anchors.rb → spec/parser/anchors_spec.rb} +7 -10
- data/spec/parser/conditionals_spec.rb +179 -0
- data/spec/parser/errors_spec.rb +51 -0
- data/spec/parser/escapes_spec.rb +132 -0
- data/spec/parser/free_space_spec.rb +130 -0
- data/spec/parser/groups_spec.rb +267 -0
- data/spec/parser/keep_spec.rb +19 -0
- data/spec/parser/posix_classes_spec.rb +27 -0
- data/spec/parser/properties_spec.rb +127 -0
- data/spec/parser/quantifiers_spec.rb +293 -0
- data/spec/parser/refcalls_spec.rb +237 -0
- data/spec/parser/set/intersections_spec.rb +127 -0
- data/spec/parser/set/ranges_spec.rb +111 -0
- data/spec/parser/sets_spec.rb +178 -0
- data/{test/parser/test_types.rb → spec/parser/types_spec.rb} +13 -20
- data/spec/scanner/all_spec.rb +18 -0
- data/{test/scanner/test_anchors.rb → spec/scanner/anchors_spec.rb} +8 -10
- data/{test/scanner/test_conditionals.rb → spec/scanner/conditionals_spec.rb} +49 -53
- data/spec/scanner/errors_spec.rb +90 -0
- data/{test/scanner/test_escapes.rb → spec/scanner/escapes_spec.rb} +8 -10
- data/{test/scanner/test_free_space.rb → spec/scanner/free_space_spec.rb} +48 -52
- data/{test/scanner/test_groups.rb → spec/scanner/groups_spec.rb} +33 -41
- data/spec/scanner/keep_spec.rb +33 -0
- data/{test/scanner/test_literals.rb → spec/scanner/literals_spec.rb} +8 -12
- data/{test/scanner/test_meta.rb → spec/scanner/meta_spec.rb} +8 -10
- data/{test/scanner/test_properties.rb → spec/scanner/properties_spec.rb} +14 -19
- data/{test/scanner/test_quantifiers.rb → spec/scanner/quantifiers_spec.rb} +7 -9
- data/{test/scanner/test_refcalls.rb → spec/scanner/refcalls_spec.rb} +9 -9
- data/{test/scanner/test_scripts.rb → spec/scanner/scripts_spec.rb} +8 -12
- data/{test/scanner/test_sets.rb → spec/scanner/sets_spec.rb} +14 -17
- data/spec/scanner/types_spec.rb +29 -0
- data/spec/scanner/unicode_blocks_spec.rb +28 -0
- data/spec/spec_helper.rb +14 -0
- data/{test → spec}/support/runner.rb +9 -8
- data/{test → spec}/support/warning_extractor.rb +5 -7
- data/spec/syntax/syntax_spec.rb +44 -0
- data/spec/syntax/syntax_token_map_spec.rb +23 -0
- data/spec/syntax/versions/1.8.6_spec.rb +38 -0
- data/spec/syntax/versions/1.9.1_spec.rb +23 -0
- data/spec/syntax/versions/1.9.3_spec.rb +22 -0
- data/spec/syntax/versions/2.0.0_spec.rb +28 -0
- data/spec/syntax/versions/2.2.0_spec.rb +22 -0
- data/spec/syntax/versions/aliases_spec.rb +119 -0
- data/spec/token/token_spec.rb +85 -0
- metadata +131 -140
- data/test/expression/test_all.rb +0 -12
- data/test/expression/test_base.rb +0 -90
- data/test/expression/test_clone.rb +0 -89
- data/test/expression/test_conditionals.rb +0 -113
- data/test/expression/test_free_space.rb +0 -35
- data/test/expression/test_set.rb +0 -84
- data/test/expression/test_strfregexp.rb +0 -230
- data/test/expression/test_subexpression.rb +0 -58
- data/test/expression/test_tests.rb +0 -99
- data/test/expression/test_to_h.rb +0 -59
- data/test/expression/test_to_s.rb +0 -104
- data/test/expression/test_traverse.rb +0 -161
- data/test/helpers.rb +0 -10
- data/test/lexer/test_all.rb +0 -41
- data/test/lexer/test_keep.rb +0 -24
- data/test/lexer/test_refcalls.rb +0 -56
- data/test/parser/set/test_intersections.rb +0 -127
- data/test/parser/set/test_ranges.rb +0 -111
- data/test/parser/test_all.rb +0 -64
- data/test/parser/test_alternation.rb +0 -92
- data/test/parser/test_conditionals.rb +0 -187
- data/test/parser/test_errors.rb +0 -63
- data/test/parser/test_escapes.rb +0 -134
- data/test/parser/test_free_space.rb +0 -139
- data/test/parser/test_groups.rb +0 -289
- data/test/parser/test_keep.rb +0 -21
- data/test/parser/test_posix_classes.rb +0 -27
- data/test/parser/test_properties.rb +0 -134
- data/test/parser/test_quantifiers.rb +0 -301
- data/test/parser/test_refcalls.rb +0 -186
- data/test/parser/test_sets.rb +0 -179
- data/test/scanner/test_all.rb +0 -38
- data/test/scanner/test_errors.rb +0 -91
- data/test/scanner/test_keep.rb +0 -35
- data/test/scanner/test_types.rb +0 -35
- data/test/scanner/test_unicode_blocks.rb +0 -30
- data/test/support/disable_autotest.rb +0 -8
- data/test/syntax/test_all.rb +0 -6
- data/test/syntax/test_syntax.rb +0 -61
- data/test/syntax/test_syntax_token_map.rb +0 -25
- data/test/syntax/versions/test_1.8.rb +0 -55
- data/test/syntax/versions/test_1.9.1.rb +0 -36
- data/test/syntax/versions/test_1.9.3.rb +0 -32
- data/test/syntax/versions/test_2.0.0.rb +0 -37
- data/test/syntax/versions/test_2.2.0.rb +0 -32
- data/test/syntax/versions/test_aliases.rb +0 -129
- data/test/syntax/versions/test_all.rb +0 -5
- data/test/test_all.rb +0 -5
- data/test/token/test_all.rb +0 -2
- data/test/token/test_token.rb +0 -107
@@ -1,301 +0,0 @@
|
|
1
|
-
require File.expand_path("../../helpers", __FILE__)
|
2
|
-
|
3
|
-
class TestRegexpParserQuantifiers < Test::Unit::TestCase
|
4
|
-
|
5
|
-
# ?: zero-or-one
|
6
|
-
def test_parse_zero_or_one_greedy
|
7
|
-
root = RP.parse('a?bc')
|
8
|
-
exp = root.expressions.first
|
9
|
-
|
10
|
-
assert_equal true, exp.quantified?
|
11
|
-
assert_equal :zero_or_one, exp.quantifier.token
|
12
|
-
assert_equal 0, exp.quantifier.min
|
13
|
-
assert_equal 1, exp.quantifier.max
|
14
|
-
assert_equal :greedy, exp.quantifier.mode
|
15
|
-
assert_equal true, exp.quantifier.greedy?
|
16
|
-
assert_equal true, exp.greedy?
|
17
|
-
|
18
|
-
assert_equal false, exp.quantifier.reluctant?
|
19
|
-
assert_equal false, exp.reluctant?
|
20
|
-
assert_equal false, exp.quantifier.possessive?
|
21
|
-
assert_equal false, exp.possessive?
|
22
|
-
end
|
23
|
-
|
24
|
-
def test_parse_zero_or_one_reluctant
|
25
|
-
root = RP.parse('a??bc')
|
26
|
-
exp = root.expressions.first
|
27
|
-
|
28
|
-
assert_equal true, exp.quantified?
|
29
|
-
assert_equal :zero_or_one, exp.quantifier.token
|
30
|
-
assert_equal 0, exp.quantifier.min
|
31
|
-
assert_equal 1, exp.quantifier.max
|
32
|
-
assert_equal :reluctant, exp.quantifier.mode
|
33
|
-
assert_equal true, exp.quantifier.reluctant?
|
34
|
-
assert_equal true, exp.reluctant?
|
35
|
-
|
36
|
-
assert_equal false, exp.quantifier.greedy?
|
37
|
-
assert_equal false, exp.greedy?
|
38
|
-
assert_equal false, exp.quantifier.possessive?
|
39
|
-
assert_equal false, exp.possessive?
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_parse_zero_or_one_possessive
|
43
|
-
root = RP.parse('a?+bc', 'ruby/1.9')
|
44
|
-
exp = root.expressions.first
|
45
|
-
|
46
|
-
assert_equal true, exp.quantified?
|
47
|
-
assert_equal :zero_or_one, exp.quantifier.token
|
48
|
-
assert_equal 0, exp.quantifier.min
|
49
|
-
assert_equal 1, exp.quantifier.max
|
50
|
-
assert_equal :possessive, exp.quantifier.mode
|
51
|
-
assert_equal true, exp.quantifier.possessive?
|
52
|
-
assert_equal true, exp.possessive?
|
53
|
-
|
54
|
-
assert_equal false, exp.quantifier.greedy?
|
55
|
-
assert_equal false, exp.greedy?
|
56
|
-
assert_equal false, exp.quantifier.reluctant?
|
57
|
-
assert_equal false, exp.reluctant?
|
58
|
-
end
|
59
|
-
|
60
|
-
# *: zero-or-more
|
61
|
-
def test_parse_zero_or_more_greedy
|
62
|
-
root = RP.parse('a*bc')
|
63
|
-
exp = root.expressions.first
|
64
|
-
|
65
|
-
assert_equal true, exp.quantified?
|
66
|
-
assert_equal :zero_or_more, exp.quantifier.token
|
67
|
-
assert_equal 0, exp.quantifier.min
|
68
|
-
assert_equal(-1, exp.quantifier.max)
|
69
|
-
assert_equal :greedy, exp.quantifier.mode
|
70
|
-
assert_equal true, exp.quantifier.greedy?
|
71
|
-
assert_equal true, exp.greedy?
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_parse_zero_or_more_reluctant
|
75
|
-
root = RP.parse('a*?bc')
|
76
|
-
exp = root.expressions.first
|
77
|
-
|
78
|
-
assert_equal true, exp.quantified?
|
79
|
-
assert_equal :zero_or_more, exp.quantifier.token
|
80
|
-
assert_equal 0, exp.quantifier.min
|
81
|
-
assert_equal(-1, exp.quantifier.max)
|
82
|
-
assert_equal :reluctant, exp.quantifier.mode
|
83
|
-
assert_equal true, exp.quantifier.reluctant?
|
84
|
-
assert_equal true, exp.reluctant?
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_parse_zero_or_more_possessive
|
88
|
-
root = RP.parse('a*+bc', 'ruby/1.9')
|
89
|
-
exp = root.expressions.first
|
90
|
-
|
91
|
-
assert_equal true, exp.quantified?
|
92
|
-
assert_equal :zero_or_more, exp.quantifier.token
|
93
|
-
assert_equal 0, exp.quantifier.min
|
94
|
-
assert_equal(-1, exp.quantifier.max)
|
95
|
-
assert_equal :possessive, exp.quantifier.mode
|
96
|
-
assert_equal true, exp.quantifier.possessive?
|
97
|
-
assert_equal true, exp.possessive?
|
98
|
-
end
|
99
|
-
|
100
|
-
# +: one-or-more
|
101
|
-
def test_parse_one_or_more_greedy
|
102
|
-
root = RP.parse('a+bc')
|
103
|
-
exp = root.expressions.first
|
104
|
-
|
105
|
-
assert_equal true, exp.quantified?
|
106
|
-
assert_equal :one_or_more, exp.quantifier.token
|
107
|
-
assert_equal 1, exp.quantifier.min
|
108
|
-
assert_equal(-1, exp.quantifier.max)
|
109
|
-
assert_equal :greedy, exp.quantifier.mode
|
110
|
-
assert_equal true, exp.quantifier.greedy?
|
111
|
-
assert_equal true, exp.greedy?
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_parse_one_or_more_reluctant
|
115
|
-
root = RP.parse('a+?bc')
|
116
|
-
exp = root.expressions.first
|
117
|
-
|
118
|
-
assert_equal true, exp.quantified?
|
119
|
-
assert_equal :one_or_more, exp.quantifier.token
|
120
|
-
assert_equal 1, exp.quantifier.min
|
121
|
-
assert_equal(-1, exp.quantifier.max)
|
122
|
-
assert_equal :reluctant, exp.quantifier.mode
|
123
|
-
assert_equal true, exp.quantifier.reluctant?
|
124
|
-
assert_equal true, exp.reluctant?
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_parse_one_or_more_possessive
|
128
|
-
root = RP.parse('a++bc', 'ruby/1.9')
|
129
|
-
exp = root.expressions.first
|
130
|
-
|
131
|
-
assert_equal true, exp.quantified?
|
132
|
-
assert_equal :one_or_more, exp.quantifier.token
|
133
|
-
assert_equal 1, exp.quantifier.min
|
134
|
-
assert_equal(-1, exp.quantifier.max)
|
135
|
-
assert_equal :possessive, exp.quantifier.mode
|
136
|
-
assert_equal true, exp.quantifier.possessive?
|
137
|
-
assert_equal true, exp.possessive?
|
138
|
-
end
|
139
|
-
|
140
|
-
# interval: min and max
|
141
|
-
def test_parse_intervals_min_max_greedy
|
142
|
-
root = RP.parse('a{2,4}bc')
|
143
|
-
exp = root.expressions.first
|
144
|
-
|
145
|
-
assert_equal true, exp.quantified?
|
146
|
-
assert_equal :interval, exp.quantifier.token
|
147
|
-
assert_equal 2, exp.quantifier.min
|
148
|
-
assert_equal 4, exp.quantifier.max
|
149
|
-
assert_equal :greedy, exp.quantifier.mode
|
150
|
-
assert_equal true, exp.quantifier.greedy?
|
151
|
-
assert_equal true, exp.greedy?
|
152
|
-
end
|
153
|
-
|
154
|
-
def test_parse_intervals_min_max_reluctant
|
155
|
-
root = RP.parse('a{3,5}?bc')
|
156
|
-
exp = root.expressions.first
|
157
|
-
|
158
|
-
assert_equal true, exp.quantified?
|
159
|
-
assert_equal :interval, exp.quantifier.token
|
160
|
-
assert_equal 3, exp.quantifier.min
|
161
|
-
assert_equal 5, exp.quantifier.max
|
162
|
-
assert_equal :reluctant, exp.quantifier.mode
|
163
|
-
assert_equal true, exp.quantifier.reluctant?
|
164
|
-
assert_equal true, exp.reluctant?
|
165
|
-
end
|
166
|
-
|
167
|
-
def test_parse_intervals_min_max_possessive
|
168
|
-
root = RP.parse('a{2,4}+bc', 'ruby/1.9')
|
169
|
-
exp = root.expressions.first
|
170
|
-
|
171
|
-
assert_equal true, exp.quantified?
|
172
|
-
assert_equal :interval, exp.quantifier.token
|
173
|
-
assert_equal 2, exp.quantifier.min
|
174
|
-
assert_equal 4, exp.quantifier.max
|
175
|
-
assert_equal :possessive, exp.quantifier.mode
|
176
|
-
assert_equal true, exp.quantifier.possessive?
|
177
|
-
assert_equal true, exp.possessive?
|
178
|
-
end
|
179
|
-
|
180
|
-
# interval: min only
|
181
|
-
def test_parse_intervals_min_only_greedy
|
182
|
-
root = RP.parse('a{2,}bc')
|
183
|
-
exp = root.expressions.first
|
184
|
-
|
185
|
-
assert_equal true, exp.quantified?
|
186
|
-
assert_equal :interval, exp.quantifier.token
|
187
|
-
assert_equal 2, exp.quantifier.min
|
188
|
-
assert_equal(-1, exp.quantifier.max)
|
189
|
-
assert_equal :greedy, exp.quantifier.mode
|
190
|
-
assert_equal true, exp.quantifier.greedy?
|
191
|
-
assert_equal true, exp.greedy?
|
192
|
-
end
|
193
|
-
|
194
|
-
def test_parse_intervals_min_only_reluctant
|
195
|
-
root = RP.parse('a{2,}?bc')
|
196
|
-
exp = root.expressions.first
|
197
|
-
|
198
|
-
assert_equal true, exp.quantified?
|
199
|
-
assert_equal :interval, exp.quantifier.token
|
200
|
-
assert_equal '{2,}?', exp.quantifier.text
|
201
|
-
assert_equal 2, exp.quantifier.min
|
202
|
-
assert_equal(-1, exp.quantifier.max)
|
203
|
-
assert_equal :reluctant, exp.quantifier.mode
|
204
|
-
assert_equal true, exp.quantifier.reluctant?
|
205
|
-
assert_equal true, exp.reluctant?
|
206
|
-
end
|
207
|
-
|
208
|
-
def test_parse_intervals_min_only_possessive
|
209
|
-
root = RP.parse('a{3,}+bc', 'ruby/1.9')
|
210
|
-
exp = root.expressions.first
|
211
|
-
|
212
|
-
assert_equal true, exp.quantified?
|
213
|
-
assert_equal :interval, exp.quantifier.token
|
214
|
-
assert_equal '{3,}+', exp.quantifier.text
|
215
|
-
assert_equal 3, exp.quantifier.min
|
216
|
-
assert_equal(-1, exp.quantifier.max)
|
217
|
-
assert_equal :possessive, exp.quantifier.mode
|
218
|
-
assert_equal true, exp.quantifier.possessive?
|
219
|
-
assert_equal true, exp.possessive?
|
220
|
-
end
|
221
|
-
|
222
|
-
# interval: max only
|
223
|
-
def test_parse_intervals_max_only_greedy
|
224
|
-
root = RP.parse('a{,2}bc')
|
225
|
-
exp = root.expressions.first
|
226
|
-
|
227
|
-
assert_equal true, exp.quantified?
|
228
|
-
assert_equal :interval, exp.quantifier.token
|
229
|
-
assert_equal 0, exp.quantifier.min
|
230
|
-
assert_equal 2, exp.quantifier.max
|
231
|
-
assert_equal :greedy, exp.quantifier.mode
|
232
|
-
assert_equal true, exp.quantifier.greedy?
|
233
|
-
assert_equal true, exp.greedy?
|
234
|
-
end
|
235
|
-
|
236
|
-
def test_parse_intervals_max_only_reluctant
|
237
|
-
root = RP.parse('a{,4}?bc')
|
238
|
-
exp = root.expressions.first
|
239
|
-
|
240
|
-
assert_equal true, exp.quantified?
|
241
|
-
assert_equal :interval, exp.quantifier.token
|
242
|
-
assert_equal 0, exp.quantifier.min
|
243
|
-
assert_equal 4, exp.quantifier.max
|
244
|
-
assert_equal :reluctant, exp.quantifier.mode
|
245
|
-
assert_equal true, exp.quantifier.reluctant?
|
246
|
-
assert_equal true, exp.reluctant?
|
247
|
-
end
|
248
|
-
|
249
|
-
def test_parse_intervals_max_only_possessive
|
250
|
-
root = RP.parse('a{,3}+bc', 'ruby/1.9')
|
251
|
-
exp = root.expressions.first
|
252
|
-
|
253
|
-
assert_equal true, exp.quantified?
|
254
|
-
assert_equal :interval, exp.quantifier.token
|
255
|
-
assert_equal 0, exp.quantifier.min
|
256
|
-
assert_equal 3, exp.quantifier.max
|
257
|
-
assert_equal :possessive, exp.quantifier.mode
|
258
|
-
assert_equal true, exp.quantifier.possessive?
|
259
|
-
assert_equal true, exp.possessive?
|
260
|
-
end
|
261
|
-
|
262
|
-
# interval: exact
|
263
|
-
def test_parse_intervals_exact_greedy
|
264
|
-
root = RP.parse('a{2}bc')
|
265
|
-
exp = root.expressions.first
|
266
|
-
|
267
|
-
assert_equal true, exp.quantified?
|
268
|
-
assert_equal :interval, exp.quantifier.token
|
269
|
-
assert_equal 2, exp.quantifier.min
|
270
|
-
assert_equal 2, exp.quantifier.max
|
271
|
-
assert_equal :greedy, exp.quantifier.mode
|
272
|
-
assert_equal true, exp.quantifier.greedy?
|
273
|
-
assert_equal true, exp.greedy?
|
274
|
-
end
|
275
|
-
|
276
|
-
def test_parse_intervals_exact_reluctant
|
277
|
-
root = RP.parse('a{3}?bc')
|
278
|
-
exp = root.expressions.first
|
279
|
-
|
280
|
-
assert_equal true, exp.quantified?
|
281
|
-
assert_equal :interval, exp.quantifier.token
|
282
|
-
assert_equal 3, exp.quantifier.min
|
283
|
-
assert_equal 3, exp.quantifier.max
|
284
|
-
assert_equal :reluctant, exp.quantifier.mode
|
285
|
-
assert_equal true, exp.quantifier.reluctant?
|
286
|
-
assert_equal true, exp.reluctant?
|
287
|
-
end
|
288
|
-
|
289
|
-
def test_parse_intervals_exact_possessive
|
290
|
-
root = RP.parse('a{3}+bc', 'ruby/1.9')
|
291
|
-
exp = root.expressions.first
|
292
|
-
|
293
|
-
assert_equal true, exp.quantified?
|
294
|
-
assert_equal :interval, exp.quantifier.token
|
295
|
-
assert_equal 3, exp.quantifier.min
|
296
|
-
assert_equal 3, exp.quantifier.max
|
297
|
-
assert_equal :possessive, exp.quantifier.mode
|
298
|
-
assert_equal true, exp.quantifier.possessive?
|
299
|
-
assert_equal true, exp.possessive?
|
300
|
-
end
|
301
|
-
end
|
@@ -1,186 +0,0 @@
|
|
1
|
-
require File.expand_path("../../helpers", __FILE__)
|
2
|
-
|
3
|
-
class TestParserRefcalls < Test::Unit::TestCase
|
4
|
-
def test_parse_traditional_number_backref
|
5
|
-
root = RP.parse('(abc)\1', 'ruby/1.9')
|
6
|
-
exp = root[1]
|
7
|
-
|
8
|
-
assert_instance_of Backreference::Number, exp
|
9
|
-
assert_equal 1, exp.number
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_parse_backref_named_ab
|
13
|
-
root = RP.parse('(?<X>abc)\k<X>', 'ruby/1.9')
|
14
|
-
exp = root[1]
|
15
|
-
|
16
|
-
assert_instance_of Backreference::Name, exp
|
17
|
-
assert_equal 'X', exp.name
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_parse_backref_named_sq
|
21
|
-
root = RP.parse("(?<X>abc)\\k'X'", 'ruby/1.9')
|
22
|
-
exp = root[1]
|
23
|
-
|
24
|
-
assert_instance_of Backreference::Name, exp
|
25
|
-
assert_equal 'X', exp.name
|
26
|
-
end
|
27
|
-
|
28
|
-
def test_parse_backref_number_ab
|
29
|
-
root = RP.parse('(abc)\k<1>', 'ruby/1.9')
|
30
|
-
exp = root[1]
|
31
|
-
|
32
|
-
assert_instance_of Backreference::Number, exp
|
33
|
-
assert_equal 1, exp.number
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_parse_backref_number_sq
|
37
|
-
root = RP.parse("(abc)\\k'1'", 'ruby/1.9')
|
38
|
-
exp = root[1]
|
39
|
-
|
40
|
-
assert_instance_of Backreference::Number, exp
|
41
|
-
assert_equal 1, exp.number
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_parse_backref_number_relative_ab
|
45
|
-
root = RP.parse('(abc)\k<-1>', 'ruby/1.9')
|
46
|
-
exp = root[1]
|
47
|
-
|
48
|
-
assert_instance_of Backreference::NumberRelative, exp
|
49
|
-
assert_equal(-1, exp.number)
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_parse_backref_number_relative_sq
|
53
|
-
root = RP.parse("(abc)\\k'-1'", 'ruby/1.9')
|
54
|
-
exp = root[1]
|
55
|
-
|
56
|
-
assert_instance_of Backreference::NumberRelative, exp
|
57
|
-
assert_equal(-1, exp.number)
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_parse_backref_name_call_ab
|
61
|
-
root = RP.parse('(?<X>abc)\g<X>', 'ruby/1.9')
|
62
|
-
exp = root[1]
|
63
|
-
|
64
|
-
assert_instance_of Backreference::NameCall, exp
|
65
|
-
assert_equal 'X', exp.name
|
66
|
-
end
|
67
|
-
|
68
|
-
def test_parse_backref_name_call_sq
|
69
|
-
root = RP.parse("(?<X>abc)\\g'X'", 'ruby/1.9')
|
70
|
-
exp = root[1]
|
71
|
-
|
72
|
-
assert_instance_of Backreference::NameCall, exp
|
73
|
-
assert_equal 'X', exp.name
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_parse_backref_number_call_ab
|
77
|
-
root = RP.parse('(abc)\g<1>', 'ruby/1.9')
|
78
|
-
exp = root[1]
|
79
|
-
|
80
|
-
assert_instance_of Backreference::NumberCall, exp
|
81
|
-
assert_equal 1, exp.number
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_parse_backref_number_call_sq
|
85
|
-
root = RP.parse("(abc)\\g'1'", 'ruby/1.9')
|
86
|
-
exp = root[1]
|
87
|
-
|
88
|
-
assert_instance_of Backreference::NumberCall, exp
|
89
|
-
assert_equal 1, exp.number
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_parse_backref_number_relative_call_ab
|
93
|
-
root = RP.parse('(abc)\g<-1>', 'ruby/1.9')
|
94
|
-
exp = root[1]
|
95
|
-
|
96
|
-
assert_instance_of Backreference::NumberCallRelative, exp
|
97
|
-
assert_equal(-1, exp.number)
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_parse_backref_number_relative_call_sq
|
101
|
-
root = RP.parse("(abc)\\g'-1'", 'ruby/1.9')
|
102
|
-
exp = root[1]
|
103
|
-
|
104
|
-
assert_instance_of Backreference::NumberCallRelative, exp
|
105
|
-
assert_equal(-1, exp.number)
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_parse_backref_number_relative_forward_call_ab
|
109
|
-
root = RP.parse('\g<+1>(abc)', 'ruby/1.9')
|
110
|
-
exp = root[0]
|
111
|
-
|
112
|
-
assert_instance_of Backreference::NumberCallRelative, exp
|
113
|
-
assert_equal 1, exp.number
|
114
|
-
end
|
115
|
-
|
116
|
-
def test_parse_backref_number_relative_forward_call_sq
|
117
|
-
root = RP.parse("\\g'+1'(abc)", 'ruby/1.9')
|
118
|
-
exp = root[0]
|
119
|
-
|
120
|
-
assert_instance_of Backreference::NumberCallRelative, exp
|
121
|
-
assert_equal 1, exp.number
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_parse_backref_name_recursion_level_ab
|
125
|
-
root = RP.parse('(?<X>abc)\k<X-0>', 'ruby/1.9')
|
126
|
-
exp = root[1]
|
127
|
-
|
128
|
-
assert_instance_of Backreference::NameRecursionLevel, exp
|
129
|
-
assert_equal 'X', exp.name
|
130
|
-
assert_equal 0, exp.recursion_level
|
131
|
-
end
|
132
|
-
|
133
|
-
def test_parse_backref_name_recursion_level_sq
|
134
|
-
root = RP.parse("(?<X>abc)\\k'X-0'", 'ruby/1.9')
|
135
|
-
exp = root[1]
|
136
|
-
|
137
|
-
assert_instance_of Backreference::NameRecursionLevel, exp
|
138
|
-
assert_equal 'X', exp.name
|
139
|
-
assert_equal 0, exp.recursion_level
|
140
|
-
end
|
141
|
-
|
142
|
-
def test_parse_backref_number_recursion_level_ab
|
143
|
-
root = RP.parse('(abc)\k<1-0>', 'ruby/1.9')
|
144
|
-
exp = root[1]
|
145
|
-
|
146
|
-
assert_instance_of Backreference::NumberRecursionLevel, exp
|
147
|
-
assert_equal 1, exp.number
|
148
|
-
assert_equal 0, exp.recursion_level
|
149
|
-
end
|
150
|
-
|
151
|
-
def test_parse_backref_number_recursion_level_sq
|
152
|
-
root = RP.parse("(abc)\\k'1-0'", 'ruby/1.9')
|
153
|
-
exp = root[1]
|
154
|
-
|
155
|
-
assert_instance_of Backreference::NumberRecursionLevel, exp
|
156
|
-
assert_equal 1, exp.number
|
157
|
-
assert_equal 0, exp.recursion_level
|
158
|
-
end
|
159
|
-
|
160
|
-
def test_parse_backref_negative_number_recursion_level
|
161
|
-
root = RP.parse("(abc)\\k'-1+0'", 'ruby/1.9')
|
162
|
-
exp = root[1]
|
163
|
-
|
164
|
-
assert_instance_of Backreference::NumberRecursionLevel, exp
|
165
|
-
assert_equal(-1, exp.number)
|
166
|
-
assert_equal 0, exp.recursion_level
|
167
|
-
end
|
168
|
-
|
169
|
-
def test_parse_backref_number_positive_recursion_level
|
170
|
-
root = RP.parse("(abc)\\k'1+1'", 'ruby/1.9')
|
171
|
-
exp = root[1]
|
172
|
-
|
173
|
-
assert_instance_of Backreference::NumberRecursionLevel, exp
|
174
|
-
assert_equal 1, exp.number
|
175
|
-
assert_equal 1, exp.recursion_level
|
176
|
-
end
|
177
|
-
|
178
|
-
def test_parse_backref_number_negative_recursion_level
|
179
|
-
root = RP.parse("(abc)\\k'1-1'", 'ruby/1.9')
|
180
|
-
exp = root[1]
|
181
|
-
|
182
|
-
assert_instance_of Backreference::NumberRecursionLevel, exp
|
183
|
-
assert_equal 1, exp.number
|
184
|
-
assert_equal(-1, exp.recursion_level)
|
185
|
-
end
|
186
|
-
end
|