regexp_parser 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/regexp_parser/expression.rb +6 -43
- data/lib/regexp_parser/expression/classes/conditional.rb +3 -2
- data/lib/regexp_parser/expression/classes/escape.rb +0 -4
- data/lib/regexp_parser/expression/methods/match.rb +13 -0
- data/lib/regexp_parser/expression/methods/options.rb +35 -0
- data/lib/regexp_parser/expression/methods/strfregexp.rb +0 -1
- data/lib/regexp_parser/expression/methods/tests.rb +6 -15
- data/lib/regexp_parser/expression/sequence.rb +3 -2
- data/lib/regexp_parser/expression/sequence_operation.rb +2 -6
- data/lib/regexp_parser/lexer.rb +0 -21
- data/lib/regexp_parser/parser.rb +22 -21
- data/lib/regexp_parser/scanner.rb +1159 -1329
- data/lib/regexp_parser/scanner/char_type.rl +0 -3
- data/lib/regexp_parser/scanner/scanner.rl +82 -190
- data/lib/regexp_parser/version.rb +1 -1
- data/spec/expression/base_spec.rb +14 -0
- data/spec/expression/methods/match_length_spec.rb +13 -0
- data/spec/expression/methods/match_spec.rb +25 -0
- data/spec/expression/methods/tests_spec.rb +2 -0
- data/spec/expression/options_spec.rb +128 -0
- data/spec/expression/root_spec.rb +9 -0
- data/spec/expression/sequence_spec.rb +9 -0
- data/spec/lexer/conditionals_spec.rb +49 -119
- data/spec/lexer/escapes_spec.rb +8 -32
- data/spec/lexer/keep_spec.rb +5 -17
- data/spec/lexer/literals_spec.rb +73 -110
- data/spec/lexer/nesting_spec.rb +86 -117
- data/spec/lexer/refcalls_spec.rb +51 -50
- data/spec/parser/all_spec.rb +13 -1
- data/spec/parser/anchors_spec.rb +9 -23
- data/spec/parser/conditionals_spec.rb +9 -9
- data/spec/parser/errors_spec.rb +22 -43
- data/spec/parser/escapes_spec.rb +33 -44
- data/spec/parser/groups_spec.rb +98 -257
- data/spec/parser/keep_spec.rb +2 -15
- data/spec/parser/posix_classes_spec.rb +5 -24
- data/spec/parser/properties_spec.rb +42 -54
- data/spec/parser/quantifiers_spec.rb +41 -283
- data/spec/parser/refcalls_spec.rb +60 -185
- data/spec/parser/set/intersections_spec.rb +17 -17
- data/spec/parser/set/ranges_spec.rb +17 -17
- data/spec/parser/sets_spec.rb +5 -5
- data/spec/parser/types_spec.rb +11 -36
- data/spec/scanner/anchors_spec.rb +13 -28
- data/spec/scanner/conditionals_spec.rb +121 -173
- data/spec/scanner/errors_spec.rb +65 -87
- data/spec/scanner/escapes_spec.rb +49 -50
- data/spec/scanner/free_space_spec.rb +102 -165
- data/spec/scanner/groups_spec.rb +45 -64
- data/spec/scanner/keep_spec.rb +5 -28
- data/spec/scanner/literals_spec.rb +45 -81
- data/spec/scanner/meta_spec.rb +13 -33
- data/spec/scanner/properties_spec.rb +43 -286
- data/spec/scanner/quantifiers_spec.rb +13 -28
- data/spec/scanner/refcalls_spec.rb +32 -48
- data/spec/scanner/sets_spec.rb +88 -102
- data/spec/scanner/types_spec.rb +10 -25
- data/spec/spec_helper.rb +1 -0
- data/spec/support/shared_examples.rb +77 -0
- data/spec/syntax/syntax_spec.rb +4 -0
- data/spec/syntax/versions/1.8.6_spec.rb +12 -33
- data/spec/syntax/versions/1.9.1_spec.rb +5 -18
- data/spec/syntax/versions/1.9.3_spec.rb +4 -17
- data/spec/syntax/versions/2.0.0_spec.rb +8 -23
- data/spec/syntax/versions/2.2.0_spec.rb +4 -17
- data/spec/syntax/versions/aliases_spec.rb +25 -109
- metadata +14 -6
- data/spec/scanner/scripts_spec.rb +0 -49
- data/spec/scanner/unicode_blocks_spec.rb +0 -28
@@ -1,61 +1,66 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe('Refcall parsing') do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
4
|
+
include_examples 'parse', /(abc)\1/,
|
5
|
+
1 => [:backref, :number, Backreference::Number, number: 1]
|
6
|
+
|
7
|
+
include_examples 'parse', /(?<X>abc)\k<X>/,
|
8
|
+
1 => [:backref, :name_ref, Backreference::Name, name: 'X']
|
9
|
+
include_examples 'parse', /(?<X>abc)\k'X'/,
|
10
|
+
1 => [:backref, :name_ref, Backreference::Name, name: 'X']
|
11
|
+
|
12
|
+
include_examples 'parse', /(abc)\k<1>/,
|
13
|
+
1 => [:backref, :number_ref, Backreference::Number, number: 1]
|
14
|
+
include_examples 'parse', /(abc)\k'1'/,
|
15
|
+
1 => [:backref, :number_ref, Backreference::Number, number: 1]
|
16
|
+
|
17
|
+
include_examples 'parse', /(abc)\k<-1>/,
|
18
|
+
1 => [:backref, :number_rel_ref, Backreference::NumberRelative, number: -1]
|
19
|
+
include_examples 'parse', /(abc)\k'-1'/,
|
20
|
+
1 => [:backref, :number_rel_ref, Backreference::NumberRelative, number: -1]
|
21
|
+
|
22
|
+
include_examples 'parse', /(?<X>abc)\g<X>/,
|
23
|
+
1 => [:backref, :name_call, Backreference::NameCall, name: 'X']
|
24
|
+
include_examples 'parse', /(?<X>abc)\g'X'/,
|
25
|
+
1 => [:backref, :name_call, Backreference::NameCall, name: 'X']
|
26
|
+
|
27
|
+
include_examples 'parse', /(abc)\g<1>/,
|
28
|
+
1 => [:backref, :number_call, Backreference::NumberCall, number: 1]
|
29
|
+
include_examples 'parse', /(abc)\g'1'/,
|
30
|
+
1 => [:backref, :number_call, Backreference::NumberCall, number: 1]
|
31
|
+
|
32
|
+
include_examples 'parse', /(abc)\g<-1>/,
|
33
|
+
1 => [:backref, :number_rel_call, Backreference::NumberCallRelative, number: -1]
|
34
|
+
include_examples 'parse', /(abc)\g'-1'/,
|
35
|
+
1 => [:backref, :number_rel_call, Backreference::NumberCallRelative, number: -1]
|
36
|
+
|
37
|
+
include_examples 'parse', /\g<+1>(abc)/,
|
38
|
+
0 => [:backref, :number_rel_call, Backreference::NumberCallRelative, number: 1]
|
39
|
+
include_examples 'parse', /\g'+1'(abc)/,
|
40
|
+
0 => [:backref, :number_rel_call, Backreference::NumberCallRelative, number: 1]
|
41
|
+
|
42
|
+
include_examples 'parse', /(?<X>abc)\k<X-0>/,
|
43
|
+
1 => [:backref, :name_recursion_ref, Backreference::NameRecursionLevel,
|
44
|
+
name: 'X', recursion_level: 0]
|
45
|
+
include_examples 'parse', /(?<X>abc)\k'X-0'/,
|
46
|
+
1 => [:backref, :name_recursion_ref, Backreference::NameRecursionLevel,
|
47
|
+
name: 'X', recursion_level: 0]
|
48
|
+
|
49
|
+
include_examples 'parse', /(abc)\k<1-0>/,
|
50
|
+
1 => [:backref, :number_recursion_ref, Backreference::NumberRecursionLevel,
|
51
|
+
number: 1, recursion_level: 0]
|
52
|
+
include_examples 'parse', /(abc)\k'1-0'/,
|
53
|
+
1 => [:backref, :number_recursion_ref, Backreference::NumberRecursionLevel,
|
54
|
+
number: 1, recursion_level: 0]
|
55
|
+
include_examples 'parse', /(abc)\k'-1+0'/,
|
56
|
+
1 => [:backref, :number_recursion_ref, Backreference::NumberRecursionLevel,
|
57
|
+
number: -1, recursion_level: 0]
|
58
|
+
include_examples 'parse', /(abc)\k'1+1'/,
|
59
|
+
1 => [:backref, :number_recursion_ref, Backreference::NumberRecursionLevel,
|
60
|
+
number: 1, recursion_level: 1]
|
61
|
+
include_examples 'parse', /(abc)\k'1-1'/,
|
62
|
+
1 => [:backref, :number_recursion_ref, Backreference::NumberRecursionLevel,
|
63
|
+
number: 1, recursion_level: -1]
|
59
64
|
|
60
65
|
specify('parse backref effective_number') do
|
61
66
|
root = RP.parse('(abc)(def)\\k<-1>(ghi)\\k<-3>\\k<-1>', 'ruby/1.9')
|
@@ -76,76 +81,11 @@ RSpec.describe('Refcall parsing') do
|
|
76
81
|
exp3 = root[5]
|
77
82
|
|
78
83
|
expect([exp1, exp2, exp3]).to all be_instance_of(Backreference::NumberRelative)
|
79
|
-
|
80
84
|
expect(exp1.referenced_expression.to_s).to eq '(def)'
|
81
85
|
expect(exp2.referenced_expression.to_s).to eq '(abc)'
|
82
86
|
expect(exp3.referenced_expression.to_s).to eq '(ghi)'
|
83
87
|
end
|
84
88
|
|
85
|
-
specify('parse backref name call ab') do
|
86
|
-
root = RP.parse('(?<X>abc)\\g<X>', 'ruby/1.9')
|
87
|
-
exp = root[1]
|
88
|
-
|
89
|
-
expect(exp).to be_instance_of(Backreference::NameCall)
|
90
|
-
expect(exp.name).to eq 'X'
|
91
|
-
end
|
92
|
-
|
93
|
-
specify('parse backref name call sq') do
|
94
|
-
root = RP.parse("(?<X>abc)\\g'X'", 'ruby/1.9')
|
95
|
-
exp = root[1]
|
96
|
-
|
97
|
-
expect(exp).to be_instance_of(Backreference::NameCall)
|
98
|
-
expect(exp.name).to eq 'X'
|
99
|
-
end
|
100
|
-
|
101
|
-
specify('parse backref number call ab') do
|
102
|
-
root = RP.parse('(abc)\\g<1>', 'ruby/1.9')
|
103
|
-
exp = root[1]
|
104
|
-
|
105
|
-
expect(exp).to be_instance_of(Backreference::NumberCall)
|
106
|
-
expect(exp.number).to eq 1
|
107
|
-
end
|
108
|
-
|
109
|
-
specify('parse backref number call sq') do
|
110
|
-
root = RP.parse("(abc)\\g'1'", 'ruby/1.9')
|
111
|
-
exp = root[1]
|
112
|
-
|
113
|
-
expect(exp).to be_instance_of(Backreference::NumberCall)
|
114
|
-
expect(exp.number).to eq 1
|
115
|
-
end
|
116
|
-
|
117
|
-
specify('parse backref number relative call ab') do
|
118
|
-
root = RP.parse('(abc)\\g<-1>', 'ruby/1.9')
|
119
|
-
exp = root[1]
|
120
|
-
|
121
|
-
expect(exp).to be_instance_of(Backreference::NumberCallRelative)
|
122
|
-
expect(exp.number).to eq(-1)
|
123
|
-
end
|
124
|
-
|
125
|
-
specify('parse backref number relative call sq') do
|
126
|
-
root = RP.parse("(abc)\\g'-1'", 'ruby/1.9')
|
127
|
-
exp = root[1]
|
128
|
-
|
129
|
-
expect(exp).to be_instance_of(Backreference::NumberCallRelative)
|
130
|
-
expect(exp.number).to eq(-1)
|
131
|
-
end
|
132
|
-
|
133
|
-
specify('parse backref number relative forward call ab') do
|
134
|
-
root = RP.parse('\\g<+1>(abc)', 'ruby/1.9')
|
135
|
-
exp = root[0]
|
136
|
-
|
137
|
-
expect(exp).to be_instance_of(Backreference::NumberCallRelative)
|
138
|
-
expect(exp.number).to eq 1
|
139
|
-
end
|
140
|
-
|
141
|
-
specify('parse backref number relative forward call sq') do
|
142
|
-
root = RP.parse("\\g'+1'(abc)", 'ruby/1.9')
|
143
|
-
exp = root[0]
|
144
|
-
|
145
|
-
expect(exp).to be_instance_of(Backreference::NumberCallRelative)
|
146
|
-
expect(exp.number).to eq 1
|
147
|
-
end
|
148
|
-
|
149
89
|
specify('parse backref call effective_number') do
|
150
90
|
root = RP.parse('\\g<+1>(abc)\\g<+2>(def)(ghi)\\g<-2>', 'ruby/1.9')
|
151
91
|
exp1 = root[0]
|
@@ -153,7 +93,6 @@ RSpec.describe('Refcall parsing') do
|
|
153
93
|
exp3 = root[5]
|
154
94
|
|
155
95
|
expect([exp1, exp2, exp3]).to all be_instance_of(Backreference::NumberCallRelative)
|
156
|
-
|
157
96
|
expect(exp1.effective_number).to eq 1
|
158
97
|
expect(exp2.effective_number).to eq 3
|
159
98
|
expect(exp3.effective_number).to eq 2
|
@@ -166,72 +105,8 @@ RSpec.describe('Refcall parsing') do
|
|
166
105
|
exp3 = root[5]
|
167
106
|
|
168
107
|
expect([exp1, exp2, exp3]).to all be_instance_of(Backreference::NumberCallRelative)
|
169
|
-
|
170
108
|
expect(exp1.referenced_expression.to_s).to eq '(abc)'
|
171
109
|
expect(exp2.referenced_expression.to_s).to eq '(ghi)'
|
172
110
|
expect(exp3.referenced_expression.to_s).to eq '(def)'
|
173
111
|
end
|
174
|
-
|
175
|
-
specify('parse backref name recursion level ab') do
|
176
|
-
root = RP.parse('(?<X>abc)\\k<X-0>', 'ruby/1.9')
|
177
|
-
exp = root[1]
|
178
|
-
|
179
|
-
expect(exp).to be_instance_of(Backreference::NameRecursionLevel)
|
180
|
-
expect(exp.name).to eq 'X'
|
181
|
-
expect(exp.recursion_level).to eq 0
|
182
|
-
end
|
183
|
-
|
184
|
-
specify('parse backref name recursion level sq') do
|
185
|
-
root = RP.parse("(?<X>abc)\\k'X-0'", 'ruby/1.9')
|
186
|
-
exp = root[1]
|
187
|
-
|
188
|
-
expect(exp).to be_instance_of(Backreference::NameRecursionLevel)
|
189
|
-
expect(exp.name).to eq 'X'
|
190
|
-
expect(exp.recursion_level).to eq 0
|
191
|
-
end
|
192
|
-
|
193
|
-
specify('parse backref number recursion level ab') do
|
194
|
-
root = RP.parse('(abc)\\k<1-0>', 'ruby/1.9')
|
195
|
-
exp = root[1]
|
196
|
-
|
197
|
-
expect(exp).to be_instance_of(Backreference::NumberRecursionLevel)
|
198
|
-
expect(exp.number).to eq 1
|
199
|
-
expect(exp.recursion_level).to eq 0
|
200
|
-
end
|
201
|
-
|
202
|
-
specify('parse backref number recursion level sq') do
|
203
|
-
root = RP.parse("(abc)\\k'1-0'", 'ruby/1.9')
|
204
|
-
exp = root[1]
|
205
|
-
|
206
|
-
expect(exp).to be_instance_of(Backreference::NumberRecursionLevel)
|
207
|
-
expect(exp.number).to eq 1
|
208
|
-
expect(exp.recursion_level).to eq 0
|
209
|
-
end
|
210
|
-
|
211
|
-
specify('parse backref negative number recursion level') do
|
212
|
-
root = RP.parse("(abc)\\k'-1+0'", 'ruby/1.9')
|
213
|
-
exp = root[1]
|
214
|
-
|
215
|
-
expect(exp).to be_instance_of(Backreference::NumberRecursionLevel)
|
216
|
-
expect(exp.number).to eq(-1)
|
217
|
-
expect(exp.recursion_level).to eq 0
|
218
|
-
end
|
219
|
-
|
220
|
-
specify('parse backref number positive recursion level') do
|
221
|
-
root = RP.parse("(abc)\\k'1+1'", 'ruby/1.9')
|
222
|
-
exp = root[1]
|
223
|
-
|
224
|
-
expect(exp).to be_instance_of(Backreference::NumberRecursionLevel)
|
225
|
-
expect(exp.number).to eq 1
|
226
|
-
expect(exp.recursion_level).to eq 1
|
227
|
-
end
|
228
|
-
|
229
|
-
specify('parse backref number negative recursion level') do
|
230
|
-
root = RP.parse("(abc)\\k'1-1'", 'ruby/1.9')
|
231
|
-
exp = root[1]
|
232
|
-
|
233
|
-
expect(exp).to be_instance_of(Backreference::NumberRecursionLevel)
|
234
|
-
expect(exp.number).to eq 1
|
235
|
-
expect(exp.recursion_level).to eq(-1)
|
236
|
-
end
|
237
112
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
# edge cases with `...-&&...` and `...&&-...` are checked in test_ranges.rb
|
4
4
|
|
5
|
-
RSpec.describe('
|
5
|
+
RSpec.describe('CharacterSet::Intersection parsing') do
|
6
6
|
specify('parse set intersection') do
|
7
7
|
root = RP.parse('[a&&z]')
|
8
8
|
set = root[0]
|
@@ -22,9 +22,9 @@ RSpec.describe('SetIntersection parsing') do
|
|
22
22
|
expect(seq2.first.to_s).to eq 'z'
|
23
23
|
expect(seq2.first).to be_instance_of(Literal)
|
24
24
|
|
25
|
-
expect(set.
|
26
|
-
expect(set.
|
27
|
-
expect(set.
|
25
|
+
expect(set).not_to match 'a'
|
26
|
+
expect(set).not_to match '&'
|
27
|
+
expect(set).not_to match 'z'
|
28
28
|
end
|
29
29
|
|
30
30
|
specify('parse set intersection range and subset') do
|
@@ -46,9 +46,9 @@ RSpec.describe('SetIntersection parsing') do
|
|
46
46
|
expect(seq2.first.to_s).to eq '[^a]'
|
47
47
|
expect(seq2.first).to be_instance_of(CharacterSet)
|
48
48
|
|
49
|
-
expect(set.
|
50
|
-
expect(set.
|
51
|
-
expect(set.
|
49
|
+
expect(set).not_to match 'a'
|
50
|
+
expect(set).not_to match '&'
|
51
|
+
expect(set).to match 'b'
|
52
52
|
end
|
53
53
|
|
54
54
|
specify('parse set intersection trailing range') do
|
@@ -70,9 +70,9 @@ RSpec.describe('SetIntersection parsing') do
|
|
70
70
|
expect(seq2.first.to_s).to eq 'a-z'
|
71
71
|
expect(seq2.first).to be_instance_of(CharacterSet::Range)
|
72
72
|
|
73
|
-
expect(set.
|
74
|
-
expect(set.
|
75
|
-
expect(set.
|
73
|
+
expect(set).to match 'a'
|
74
|
+
expect(set).not_to match '&'
|
75
|
+
expect(set).not_to match 'b'
|
76
76
|
end
|
77
77
|
|
78
78
|
specify('parse set intersection type') do
|
@@ -94,9 +94,9 @@ RSpec.describe('SetIntersection parsing') do
|
|
94
94
|
expect(seq2.first.to_s).to eq '\\w'
|
95
95
|
expect(seq2.first).to be_instance_of(CharacterType::Word)
|
96
96
|
|
97
|
-
expect(set.
|
98
|
-
expect(set.
|
99
|
-
expect(set.
|
97
|
+
expect(set).to match 'a'
|
98
|
+
expect(set).not_to match '&'
|
99
|
+
expect(set).not_to match 'b'
|
100
100
|
end
|
101
101
|
|
102
102
|
specify('parse set intersection multipart') do
|
@@ -119,9 +119,9 @@ RSpec.describe('SetIntersection parsing') do
|
|
119
119
|
expect(seq3.count).to eq 3
|
120
120
|
expect(seq3.to_s).to eq 'efg'
|
121
121
|
|
122
|
-
expect(set.
|
123
|
-
expect(set.
|
124
|
-
expect(set.
|
125
|
-
expect(set.
|
122
|
+
expect(set).to match 'e'
|
123
|
+
expect(set).to match 'f'
|
124
|
+
expect(set).not_to match 'a'
|
125
|
+
expect(set).not_to match 'g'
|
126
126
|
end
|
127
127
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
RSpec.describe('
|
3
|
+
RSpec.describe('CharacterSet::Range parsing') do
|
4
4
|
specify('parse set range') do
|
5
5
|
root = RP.parse('[a-z]')
|
6
6
|
set = root[0]
|
@@ -13,7 +13,7 @@ RSpec.describe('SetRang parsing') do
|
|
13
13
|
expect(range.first).to be_instance_of(Literal)
|
14
14
|
expect(range.last.to_s).to eq 'z'
|
15
15
|
expect(range.last).to be_instance_of(Literal)
|
16
|
-
expect(set
|
16
|
+
expect(set).to match 'm'
|
17
17
|
end
|
18
18
|
|
19
19
|
specify('parse set range hex') do
|
@@ -28,7 +28,7 @@ RSpec.describe('SetRang parsing') do
|
|
28
28
|
expect(range.first).to be_instance_of(EscapeSequence::Hex)
|
29
29
|
expect(range.last.to_s).to eq '\\x99'
|
30
30
|
expect(range.last).to be_instance_of(EscapeSequence::Hex)
|
31
|
-
expect(set.
|
31
|
+
expect(set).to match '\\x50'
|
32
32
|
end
|
33
33
|
|
34
34
|
specify('parse set range unicode') do
|
@@ -43,7 +43,7 @@ RSpec.describe('SetRang parsing') do
|
|
43
43
|
expect(range.first).to be_instance_of(EscapeSequence::CodepointList)
|
44
44
|
expect(range.last.to_s).to eq '\\u1234'
|
45
45
|
expect(range.last).to be_instance_of(EscapeSequence::Codepoint)
|
46
|
-
expect(set.
|
46
|
+
expect(set).to match '\\u600'
|
47
47
|
end
|
48
48
|
|
49
49
|
specify('parse set range edge case leading dash') do
|
@@ -53,7 +53,7 @@ RSpec.describe('SetRang parsing') do
|
|
53
53
|
|
54
54
|
expect(set.count).to eq 1
|
55
55
|
expect(range.count).to eq 2
|
56
|
-
expect(set
|
56
|
+
expect(set).to match 'a'
|
57
57
|
end
|
58
58
|
|
59
59
|
specify('parse set range edge case trailing dash') do
|
@@ -63,7 +63,7 @@ RSpec.describe('SetRang parsing') do
|
|
63
63
|
|
64
64
|
expect(set.count).to eq 1
|
65
65
|
expect(range.count).to eq 2
|
66
|
-
expect(set
|
66
|
+
expect(set).to match '$'
|
67
67
|
end
|
68
68
|
|
69
69
|
specify('parse set range edge case leading negate') do
|
@@ -71,8 +71,8 @@ RSpec.describe('SetRang parsing') do
|
|
71
71
|
set = root[0]
|
72
72
|
|
73
73
|
expect(set.count).to eq 2
|
74
|
-
expect(set.
|
75
|
-
expect(set.
|
74
|
+
expect(set).to match 'a'
|
75
|
+
expect(set).not_to match 'z'
|
76
76
|
end
|
77
77
|
|
78
78
|
specify('parse set range edge case trailing negate') do
|
@@ -82,7 +82,7 @@ RSpec.describe('SetRang parsing') do
|
|
82
82
|
|
83
83
|
expect(set.count).to eq 1
|
84
84
|
expect(range.count).to eq 2
|
85
|
-
expect(set
|
85
|
+
expect(set).to match '$'
|
86
86
|
end
|
87
87
|
|
88
88
|
specify('parse set range edge case leading intersection') do
|
@@ -91,10 +91,10 @@ RSpec.describe('SetRang parsing') do
|
|
91
91
|
|
92
92
|
expect(set.count).to eq 1
|
93
93
|
expect(set.first.last.to_s).to eq '-bc'
|
94
|
-
expect(set.
|
95
|
-
expect(set.
|
96
|
-
expect(set.
|
97
|
-
expect(set.
|
94
|
+
expect(set).to match '-'
|
95
|
+
expect(set).to match 'b'
|
96
|
+
expect(set).not_to match 'a'
|
97
|
+
expect(set).not_to match 'c'
|
98
98
|
end
|
99
99
|
|
100
100
|
specify('parse set range edge case trailing intersection') do
|
@@ -103,9 +103,9 @@ RSpec.describe('SetRang parsing') do
|
|
103
103
|
|
104
104
|
expect(set.count).to eq 1
|
105
105
|
expect(set.first.first.to_s).to eq 'bc-'
|
106
|
-
expect(set.
|
107
|
-
expect(set.
|
108
|
-
expect(set.
|
109
|
-
expect(set.
|
106
|
+
expect(set).to match '-'
|
107
|
+
expect(set).to match 'b'
|
108
|
+
expect(set).not_to match 'a'
|
109
|
+
expect(set).not_to match 'c'
|
110
110
|
end
|
111
111
|
end
|
data/spec/parser/sets_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
RSpec.describe('
|
3
|
+
RSpec.describe('CharacterSet parsing') do
|
4
4
|
specify('parse set basic') do
|
5
5
|
root = RP.parse('[ab]+')
|
6
6
|
exp = root[0]
|
@@ -39,10 +39,10 @@ RSpec.describe('Set parsing') do
|
|
39
39
|
expect(exp[1]).to be_instance_of(EscapeSequence::Backspace)
|
40
40
|
expect(exp[1].text).to eq '\\b'
|
41
41
|
|
42
|
-
expect(exp.
|
43
|
-
expect(exp.
|
44
|
-
expect(exp.
|
45
|
-
expect(exp.
|
42
|
+
expect(exp).to match 'a'
|
43
|
+
expect(exp).to match "\b"
|
44
|
+
expect(exp).not_to match 'b'
|
45
|
+
expect(exp).to match 'c'
|
46
46
|
end
|
47
47
|
|
48
48
|
specify('parse set escape sequence hex') do
|