regexp_parser 2.2.0 → 2.2.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.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -2
  3. data/LICENSE +1 -1
  4. data/README.md +2 -2
  5. data/Rakefile +5 -8
  6. data/lib/regexp_parser/expression/classes/escape_sequence.rb +12 -7
  7. data/lib/regexp_parser/expression/methods/strfregexp.rb +1 -1
  8. data/lib/regexp_parser/scanner/properties/long.csv +604 -0
  9. data/lib/regexp_parser/scanner/properties/short.csv +242 -0
  10. data/lib/regexp_parser/scanner/scanner.rl +6 -4
  11. data/lib/regexp_parser/scanner.rb +126 -124
  12. data/lib/regexp_parser/syntax/base.rb +3 -5
  13. data/lib/regexp_parser/syntax/token/backreference.rb +7 -2
  14. data/lib/regexp_parser/syntax/versions/1.8.6.rb +2 -2
  15. data/lib/regexp_parser/syntax/versions/1.9.1.rb +1 -1
  16. data/lib/regexp_parser/version.rb +1 -1
  17. data/regexp_parser.gemspec +20 -22
  18. metadata +11 -143
  19. data/lib/regexp_parser/scanner/properties/long.yml +0 -607
  20. data/lib/regexp_parser/scanner/properties/short.yml +0 -245
  21. data/spec/expression/base_spec.rb +0 -104
  22. data/spec/expression/clone_spec.rb +0 -152
  23. data/spec/expression/conditional_spec.rb +0 -89
  24. data/spec/expression/free_space_spec.rb +0 -27
  25. data/spec/expression/methods/match_length_spec.rb +0 -161
  26. data/spec/expression/methods/match_spec.rb +0 -25
  27. data/spec/expression/methods/strfregexp_spec.rb +0 -224
  28. data/spec/expression/methods/tests_spec.rb +0 -99
  29. data/spec/expression/methods/traverse_spec.rb +0 -161
  30. data/spec/expression/options_spec.rb +0 -128
  31. data/spec/expression/subexpression_spec.rb +0 -50
  32. data/spec/expression/to_h_spec.rb +0 -26
  33. data/spec/expression/to_s_spec.rb +0 -108
  34. data/spec/lexer/all_spec.rb +0 -22
  35. data/spec/lexer/conditionals_spec.rb +0 -53
  36. data/spec/lexer/delimiters_spec.rb +0 -68
  37. data/spec/lexer/escapes_spec.rb +0 -14
  38. data/spec/lexer/keep_spec.rb +0 -10
  39. data/spec/lexer/literals_spec.rb +0 -64
  40. data/spec/lexer/nesting_spec.rb +0 -99
  41. data/spec/lexer/refcalls_spec.rb +0 -60
  42. data/spec/parser/all_spec.rb +0 -43
  43. data/spec/parser/alternation_spec.rb +0 -88
  44. data/spec/parser/anchors_spec.rb +0 -17
  45. data/spec/parser/conditionals_spec.rb +0 -179
  46. data/spec/parser/errors_spec.rb +0 -30
  47. data/spec/parser/escapes_spec.rb +0 -133
  48. data/spec/parser/free_space_spec.rb +0 -130
  49. data/spec/parser/groups_spec.rb +0 -108
  50. data/spec/parser/keep_spec.rb +0 -6
  51. data/spec/parser/options_spec.rb +0 -28
  52. data/spec/parser/posix_classes_spec.rb +0 -8
  53. data/spec/parser/properties_spec.rb +0 -117
  54. data/spec/parser/quantifiers_spec.rb +0 -68
  55. data/spec/parser/refcalls_spec.rb +0 -117
  56. data/spec/parser/set/intersections_spec.rb +0 -127
  57. data/spec/parser/set/ranges_spec.rb +0 -121
  58. data/spec/parser/sets_spec.rb +0 -178
  59. data/spec/parser/types_spec.rb +0 -18
  60. data/spec/scanner/all_spec.rb +0 -18
  61. data/spec/scanner/anchors_spec.rb +0 -21
  62. data/spec/scanner/conditionals_spec.rb +0 -128
  63. data/spec/scanner/delimiters_spec.rb +0 -52
  64. data/spec/scanner/errors_spec.rb +0 -67
  65. data/spec/scanner/escapes_spec.rb +0 -73
  66. data/spec/scanner/free_space_spec.rb +0 -165
  67. data/spec/scanner/groups_spec.rb +0 -61
  68. data/spec/scanner/keep_spec.rb +0 -10
  69. data/spec/scanner/literals_spec.rb +0 -39
  70. data/spec/scanner/meta_spec.rb +0 -18
  71. data/spec/scanner/options_spec.rb +0 -36
  72. data/spec/scanner/properties_spec.rb +0 -64
  73. data/spec/scanner/quantifiers_spec.rb +0 -25
  74. data/spec/scanner/refcalls_spec.rb +0 -55
  75. data/spec/scanner/sets_spec.rb +0 -151
  76. data/spec/scanner/types_spec.rb +0 -14
  77. data/spec/spec_helper.rb +0 -28
  78. data/spec/support/capturing_stderr.rb +0 -9
  79. data/spec/support/shared_examples.rb +0 -77
  80. data/spec/syntax/syntax_spec.rb +0 -48
  81. data/spec/syntax/syntax_token_map_spec.rb +0 -23
  82. data/spec/syntax/versions/1.8.6_spec.rb +0 -17
  83. data/spec/syntax/versions/1.9.1_spec.rb +0 -10
  84. data/spec/syntax/versions/1.9.3_spec.rb +0 -9
  85. data/spec/syntax/versions/2.0.0_spec.rb +0 -13
  86. data/spec/syntax/versions/2.2.0_spec.rb +0 -9
  87. data/spec/syntax/versions/aliases_spec.rb +0 -38
  88. data/spec/token/token_spec.rb +0 -85
@@ -1,245 +0,0 @@
1
- #
2
- # THIS FILE IS AUTO-GENERATED BY `rake props:update`, DO NOT EDIT
3
- #
4
- ---
5
- adlm: adlam
6
- aghb: caucasian_albanian
7
- ahex: ascii_hex_digit
8
- arab: arabic
9
- armi: imperial_aramaic
10
- armn: armenian
11
- avst: avestan
12
- bali: balinese
13
- bamu: bamum
14
- bass: bassa_vah
15
- batk: batak
16
- beng: bengali
17
- bhks: bhaiksuki
18
- bidic: bidi_control
19
- bopo: bopomofo
20
- brah: brahmi
21
- brai: braille
22
- bugi: buginese
23
- buhd: buhid
24
- c: other
25
- cakm: chakma
26
- cans: canadian_aboriginal
27
- cari: carian
28
- cc: control
29
- cf: format
30
- cher: cherokee
31
- chrs: chorasmian
32
- ci: case_ignorable
33
- cn: unassigned
34
- co: private_use
35
- combiningmark: mark
36
- copt: coptic
37
- cprt: cypriot
38
- cs: surrogate
39
- cwcf: changes_when_casefolded
40
- cwcm: changes_when_casemapped
41
- cwl: changes_when_lowercased
42
- cwt: changes_when_titlecased
43
- cwu: changes_when_uppercased
44
- cyrl: cyrillic
45
- dep: deprecated
46
- deva: devanagari
47
- di: default_ignorable_code_point
48
- dia: diacritic
49
- diak: dives_akuru
50
- dogr: dogra
51
- dsrt: deseret
52
- dupl: duployan
53
- ebase: emoji_modifier_base
54
- ecomp: emoji_component
55
- egyp: egyptian_hieroglyphs
56
- elba: elbasan
57
- elym: elymaic
58
- emod: emoji_modifier
59
- epres: emoji_presentation
60
- ethi: ethiopic
61
- ext: extender
62
- geor: georgian
63
- glag: glagolitic
64
- gong: gunjala_gondi
65
- gonm: masaram_gondi
66
- goth: gothic
67
- gran: grantha
68
- grbase: grapheme_base
69
- grek: greek
70
- grext: grapheme_extend
71
- grlink: grapheme_link
72
- gujr: gujarati
73
- guru: gurmukhi
74
- hang: hangul
75
- hani: han
76
- hano: hanunoo
77
- hatr: hatran
78
- hebr: hebrew
79
- hex: hex_digit
80
- hira: hiragana
81
- hluw: anatolian_hieroglyphs
82
- hmng: pahawh_hmong
83
- hmnp: nyiakeng_puachue_hmong
84
- hung: old_hungarian
85
- idc: id_continue
86
- ideo: ideographic
87
- ids: id_start
88
- idsb: ids_binary_operator
89
- idst: ids_trinary_operator
90
- ital: old_italic
91
- java: javanese
92
- joinc: join_control
93
- kali: kayah_li
94
- kana: katakana
95
- khar: kharoshthi
96
- khmr: khmer
97
- khoj: khojki
98
- kits: khitan_small_script
99
- knda: kannada
100
- kthi: kaithi
101
- l: letter
102
- lana: tai_tham
103
- laoo: lao
104
- latn: latin
105
- lc: cased_letter
106
- lepc: lepcha
107
- limb: limbu
108
- lina: linear_a
109
- linb: linear_b
110
- ll: lowercase_letter
111
- lm: modifier_letter
112
- lo: other_letter
113
- loe: logical_order_exception
114
- lt: titlecase_letter
115
- lu: uppercase_letter
116
- lyci: lycian
117
- lydi: lydian
118
- m: mark
119
- mahj: mahajani
120
- maka: makasar
121
- mand: mandaic
122
- mani: manichaean
123
- marc: marchen
124
- mc: spacing_mark
125
- me: enclosing_mark
126
- medf: medefaidrin
127
- mend: mende_kikakui
128
- merc: meroitic_cursive
129
- mero: meroitic_hieroglyphs
130
- mlym: malayalam
131
- mn: nonspacing_mark
132
- mong: mongolian
133
- mroo: mro
134
- mtei: meetei_mayek
135
- mult: multani
136
- mymr: myanmar
137
- "n": number
138
- nand: nandinagari
139
- narb: old_north_arabian
140
- nbat: nabataean
141
- nchar: noncharacter_code_point
142
- nd: decimal_number
143
- nkoo: nko
144
- nl: letter_number
145
- 'no': other_number
146
- nshu: nushu
147
- oalpha: other_alphabetic
148
- odi: other_default_ignorable_code_point
149
- ogam: ogham
150
- ogrext: other_grapheme_extend
151
- oidc: other_id_continue
152
- oids: other_id_start
153
- olck: ol_chiki
154
- olower: other_lowercase
155
- omath: other_math
156
- orkh: old_turkic
157
- orya: oriya
158
- osge: osage
159
- osma: osmanya
160
- oupper: other_uppercase
161
- p: punctuation
162
- palm: palmyrene
163
- patsyn: pattern_syntax
164
- patws: pattern_white_space
165
- pauc: pau_cin_hau
166
- pc: connector_punctuation
167
- pcm: prepended_concatenation_mark
168
- pd: dash_punctuation
169
- pe: close_punctuation
170
- perm: old_permic
171
- pf: final_punctuation
172
- phag: phags_pa
173
- phli: inscriptional_pahlavi
174
- phlp: psalter_pahlavi
175
- phnx: phoenician
176
- pi: initial_punctuation
177
- plrd: miao
178
- po: other_punctuation
179
- prti: inscriptional_parthian
180
- ps: open_punctuation
181
- qaac: coptic
182
- qaai: inherited
183
- qmark: quotation_mark
184
- ri: regional_indicator
185
- rjng: rejang
186
- rohg: hanifi_rohingya
187
- runr: runic
188
- s: symbol
189
- samr: samaritan
190
- sarb: old_south_arabian
191
- saur: saurashtra
192
- sc: currency_symbol
193
- sd: soft_dotted
194
- sgnw: signwriting
195
- shaw: shavian
196
- shrd: sharada
197
- sidd: siddham
198
- sind: khudawadi
199
- sinh: sinhala
200
- sk: modifier_symbol
201
- sm: math_symbol
202
- so: other_symbol
203
- sogd: sogdian
204
- sogo: old_sogdian
205
- sora: sora_sompeng
206
- soyo: soyombo
207
- sterm: sentence_terminal
208
- sund: sundanese
209
- sylo: syloti_nagri
210
- syrc: syriac
211
- tagb: tagbanwa
212
- takr: takri
213
- tale: tai_le
214
- talu: new_tai_lue
215
- taml: tamil
216
- tang: tangut
217
- tavt: tai_viet
218
- telu: telugu
219
- term: terminal_punctuation
220
- tfng: tifinagh
221
- tglg: tagalog
222
- thaa: thaana
223
- tibt: tibetan
224
- tirh: tirhuta
225
- ugar: ugaritic
226
- uideo: unified_ideograph
227
- vaii: vai
228
- vs: variation_selector
229
- wara: warang_citi
230
- wcho: wancho
231
- wspace: white_space
232
- xidc: xid_continue
233
- xids: xid_start
234
- xpeo: old_persian
235
- xsux: cuneiform
236
- yezi: yezidi
237
- yiii: yi
238
- z: separator
239
- zanb: zanabazar_square
240
- zinh: inherited
241
- zl: line_separator
242
- zp: paragraph_separator
243
- zs: space_separator
244
- zyyy: common
245
- zzzz: unknown
@@ -1,104 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe(Regexp::Expression::Base) do
4
- specify('#to_re') do
5
- re_text = '^a*(b([cde]+))+f?$'
6
-
7
- re = RP.parse(re_text).to_re
8
-
9
- expect(re).to be_a(::Regexp)
10
- expect(re_text).to eq re.source
11
- end
12
-
13
- specify('#level') do
14
- regexp = /^a(b(c(d)))e$/
15
- root = RP.parse(regexp)
16
-
17
- ['^', 'a', '(b(c(d)))', 'e', '$'].each_with_index do |t, i|
18
- expect(root[i].to_s).to eq t
19
- expect(root[i].level).to eq 0
20
- end
21
-
22
- expect(root[2][0].to_s).to eq 'b'
23
- expect(root[2][0].level).to eq 1
24
-
25
- expect(root[2][1][0].to_s).to eq 'c'
26
- expect(root[2][1][0].level).to eq 2
27
-
28
- expect(root[2][1][1][0].to_s).to eq 'd'
29
- expect(root[2][1][1][0].level).to eq 3
30
- end
31
-
32
- specify('#terminal?') do
33
- root = RP.parse('^a([b]+)c$')
34
-
35
- expect(root).not_to be_terminal
36
-
37
- expect(root[0]).to be_terminal
38
- expect(root[1]).to be_terminal
39
- expect(root[2]).not_to be_terminal
40
- expect(root[2][0]).not_to be_terminal
41
- expect(root[2][0][0]).to be_terminal
42
- expect(root[3]).to be_terminal
43
- expect(root[4]).to be_terminal
44
- end
45
-
46
- specify('alt #terminal?') do
47
- root = RP.parse('^(ab|cd)$')
48
-
49
- expect(root).not_to be_terminal
50
-
51
- expect(root[0]).to be_terminal
52
- expect(root[1]).not_to be_terminal
53
- expect(root[1][0]).not_to be_terminal
54
- expect(root[1][0][0]).not_to be_terminal
55
- expect(root[1][0][0][0]).to be_terminal
56
- expect(root[1][0][1]).not_to be_terminal
57
- expect(root[1][0][1][0]).to be_terminal
58
- end
59
-
60
- specify('#coded_offset') do
61
- root = RP.parse('^a*(b+(c?))$')
62
-
63
- expect(root.coded_offset).to eq '@0+12'
64
-
65
- [
66
- ['@0+1', '^'],
67
- ['@1+2', 'a*'],
68
- ['@3+8', '(b+(c?))'],
69
- ['@11+1', '$'],
70
- ].each_with_index do |check, i|
71
- against = [root[i].coded_offset, root[i].to_s]
72
-
73
- expect(against).to eq check
74
- end
75
-
76
- expect([root[2][0].coded_offset, root[2][0].to_s]).to eq ['@4+2', 'b+']
77
- expect([root[2][1].coded_offset, root[2][1].to_s]).to eq ['@6+4', '(c?)']
78
- expect([root[2][1][0].coded_offset, root[2][1][0].to_s]).to eq ['@7+2', 'c?']
79
- end
80
-
81
- specify('#quantity') do
82
- expect(RP.parse(/aa/)[0].quantity).to eq [nil, nil]
83
- expect(RP.parse(/a?/)[0].quantity).to eq [0, 1]
84
- expect(RP.parse(/a*/)[0].quantity).to eq [0, -1]
85
- expect(RP.parse(/a+/)[0].quantity).to eq [1, -1]
86
- end
87
-
88
- specify('#repetitions') do
89
- expect(RP.parse(/aa/)[0].repetitions).to eq 1..1
90
- expect(RP.parse(/a?/)[0].repetitions).to eq 0..1
91
- expect(RP.parse(/a*/)[0].repetitions).to eq 0..(Float::INFINITY)
92
- expect(RP.parse(/a+/)[0].repetitions).to eq 1..(Float::INFINITY)
93
- end
94
-
95
- specify('#base_length') do
96
- expect(RP.parse(/(aa)/)[0].base_length).to eq 4
97
- expect(RP.parse(/(aa){42}/)[0].base_length).to eq 4
98
- end
99
-
100
- specify('#full_length') do
101
- expect(RP.parse(/(aa)/)[0].full_length).to eq 4
102
- expect(RP.parse(/(aa){42}/)[0].full_length).to eq 8
103
- end
104
- end
@@ -1,152 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe('Expression#clone') do
4
- specify('Base#clone') do
5
- root = RP.parse(/^(?i:a)b+$/i)
6
- copy = root.clone
7
-
8
- expect(copy.to_s).to eq root.to_s
9
-
10
- expect(root.object_id).not_to eq copy.object_id
11
- expect(root.text).to eq copy.text
12
- expect(root.text.object_id).not_to eq copy.text.object_id
13
-
14
- root_1 = root[1]
15
- copy_1 = copy[1]
16
-
17
- expect(root_1.options).to eq copy_1.options
18
- expect(root_1.options.object_id).not_to eq copy_1.options.object_id
19
-
20
- root_2 = root[2]
21
- copy_2 = copy[2]
22
-
23
- expect(root_2).to be_quantified
24
- expect(copy_2).to be_quantified
25
- expect(root_2.quantifier.text).to eq copy_2.quantifier.text
26
- expect(root_2.quantifier.text.object_id).not_to eq copy_2.quantifier.text.object_id
27
- expect(root_2.quantifier.object_id).not_to eq copy_2.quantifier.object_id
28
-
29
- # regression test
30
- expect { root_2.clone }.not_to(change { root_2.quantifier.object_id })
31
- expect { root_2.clone }.not_to(change { root_2.quantifier.text.object_id })
32
- end
33
-
34
- specify('Subexpression#clone') do
35
- root = RP.parse(/^a(b([cde])f)g$/)
36
- copy = root.clone
37
-
38
- expect(copy.to_s).to eq root.to_s
39
-
40
- expect(root).to respond_to(:expressions)
41
- expect(copy).to respond_to(:expressions)
42
- expect(root.expressions.object_id).not_to eq copy.expressions.object_id
43
- copy.expressions.each_with_index do |exp, index|
44
- expect(root[index].object_id).not_to eq exp.object_id
45
- end
46
- copy[2].each_with_index do |exp, index|
47
- expect(root[2][index].object_id).not_to eq exp.object_id
48
- end
49
-
50
- # regression test
51
- expect { root.clone }.not_to(change { root.expressions.object_id })
52
- end
53
-
54
- specify('Group::Named#clone') do
55
- root = RP.parse('^(?<somename>a)+bc$')
56
- copy = root.clone
57
-
58
- expect(copy.to_s).to eq root.to_s
59
-
60
- root_1 = root[1]
61
- copy_1 = copy[1]
62
-
63
- expect(root_1.name).to eq copy_1.name
64
- expect(root_1.name.object_id).not_to eq copy_1.name.object_id
65
- expect(root_1.text).to eq copy_1.text
66
- expect(root_1.expressions.object_id).not_to eq copy_1.expressions.object_id
67
- copy_1.expressions.each_with_index do |exp, index|
68
- expect(root_1[index].object_id).not_to eq exp.object_id
69
- end
70
-
71
- # regression test
72
- expect { root_1.clone }.not_to(change { root_1.name.object_id })
73
- end
74
-
75
- specify('Group::Options#clone') do
76
- root = RP.parse('foo(?i)bar')
77
- copy = root.clone
78
-
79
- expect(copy.to_s).to eq root.to_s
80
-
81
- root_1 = root[1]
82
- copy_1 = copy[1]
83
-
84
- expect(root_1.option_changes).to eq copy_1.option_changes
85
- expect(root_1.option_changes.object_id).not_to eq copy_1.option_changes.object_id
86
-
87
- # regression test
88
- expect { root_1.clone }.not_to(change { root_1.option_changes.object_id })
89
- end
90
-
91
- specify('Backreference::Base#clone') do
92
- root = RP.parse('(foo)\1')
93
- copy = root.clone
94
-
95
- expect(copy.to_s).to eq root.to_s
96
-
97
- root_1 = root[1]
98
- copy_1 = copy[1]
99
-
100
- expect(root_1.referenced_expression.to_s).to eq copy_1.referenced_expression.to_s
101
- expect(root_1.referenced_expression.object_id).not_to eq copy_1.referenced_expression.object_id
102
-
103
- # regression test
104
- expect { root_1.clone }.not_to(change { root_1.referenced_expression.object_id })
105
- end
106
-
107
- specify('Sequence#clone') do
108
- root = RP.parse(/(a|b)/)
109
- copy = root.clone
110
-
111
- # regression test
112
- expect(copy.to_s).to eq root.to_s
113
-
114
- root_seq_op = root[0][0]
115
- copy_seq_op = copy[0][0]
116
- root_seq_1 = root[0][0][0]
117
- copy_seq_1 = copy[0][0][0]
118
-
119
- expect(root_seq_op.object_id).not_to eq copy_seq_op.object_id
120
- expect(root_seq_1.object_id).not_to eq copy_seq_1.object_id
121
- copy_seq_1.expressions.each_with_index do |exp, index|
122
- expect(root_seq_1[index].object_id).not_to eq exp.object_id
123
- end
124
- end
125
-
126
- describe('Base#unquantified_clone') do
127
- it 'produces a clone' do
128
- root = RP.parse(/^a(b([cde])f)g$/)
129
- copy = root.unquantified_clone
130
-
131
- expect(copy.to_s).to eq root.to_s
132
-
133
- expect(copy.object_id).not_to eq root.object_id
134
- end
135
-
136
- it 'does not carry over the callee quantifier' do
137
- expect(RP.parse(/a{3}/)[0]).to be_quantified
138
- expect(RP.parse(/a{3}/)[0].unquantified_clone).not_to be_quantified
139
-
140
- expect(RP.parse(/[a]{3}/)[0]).to be_quantified
141
- expect(RP.parse(/[a]{3}/)[0].unquantified_clone).not_to be_quantified
142
-
143
- expect(RP.parse(/(a|b){3}/)[0]).to be_quantified
144
- expect(RP.parse(/(a|b){3}/)[0].unquantified_clone).not_to be_quantified
145
- end
146
-
147
- it 'keeps quantifiers of callee children' do
148
- expect(RP.parse(/(a{3}){3}/)[0][0]).to be_quantified
149
- expect(RP.parse(/(a{3}){3}/)[0].unquantified_clone[0]).to be_quantified
150
- end
151
- end
152
- end
@@ -1,89 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe(Regexp::Expression::Conditional) do
4
- let(:root) { RP.parse('^(a(b))(b(?(1)c|(?(2)d|(?(3)e|f)))g)$') }
5
- let(:cond_1) { root[2][1] }
6
- let(:cond_2) { root[2][1][2][0] }
7
- let(:cond_3) { root[2][1][2][0][2][0] }
8
-
9
- specify('root level') do
10
- [
11
- '^',
12
- '(a(b))',
13
- '(b(?(1)c|(?(2)d|(?(3)e|f)))g)',
14
- '$'
15
- ].each_with_index do |t, i|
16
- expect(root[i].conditional_level).to eq 0
17
- expect(root[i].to_s).to eq t
18
- end
19
-
20
- expect(root[2][0].to_s).to eq 'b'
21
- expect(root[2][0].conditional_level).to eq 0
22
- end
23
-
24
- specify('level one') do
25
- condition = cond_1.condition
26
- branch_1 = cond_1.branches.first
27
-
28
- expect(condition).to be_a Conditional::Condition
29
- expect(condition.to_s).to eq '(1)'
30
- expect(condition.conditional_level).to eq 1
31
-
32
- expect(branch_1).to be_a Conditional::Branch
33
- expect(branch_1.to_s).to eq 'c'
34
- expect(branch_1.conditional_level).to eq 1
35
-
36
- expect(branch_1.first.to_s).to eq 'c'
37
- expect(branch_1.first.conditional_level).to eq 1
38
- end
39
-
40
- specify('level two') do
41
- condition = cond_2.condition
42
- branch_1 = cond_2.branches.first
43
- branch_2 = cond_2.branches.last
44
-
45
- expect(cond_2.to_s).to start_with '(?'
46
- expect(cond_2.conditional_level).to eq 1
47
-
48
- expect(condition).to be_a Conditional::Condition
49
- expect(condition.to_s).to eq '(2)'
50
- expect(condition.conditional_level).to eq 2
51
-
52
- expect(branch_1).to be_a Conditional::Branch
53
- expect(branch_1.to_s).to eq 'd'
54
- expect(branch_1.conditional_level).to eq 2
55
-
56
- expect(branch_1.first.to_s).to eq 'd'
57
- expect(branch_1.first.conditional_level).to eq 2
58
-
59
- expect(branch_2.first.to_s).to start_with '(?'
60
- expect(branch_2.first.conditional_level).to eq 2
61
- end
62
-
63
- specify('level three') do
64
- condition = cond_3.condition
65
- branch_1 = cond_3.branches.first
66
- branch_2 = cond_3.branches.last
67
-
68
- expect(condition).to be_a Conditional::Condition
69
- expect(condition.to_s).to eq '(3)'
70
- expect(condition.conditional_level).to eq 3
71
-
72
- expect(cond_3.to_s).to eq '(?(3)e|f)'
73
- expect(cond_3.conditional_level).to eq 2
74
-
75
- expect(branch_1).to be_a Conditional::Branch
76
- expect(branch_1.to_s).to eq 'e'
77
- expect(branch_1.conditional_level).to eq 3
78
-
79
- expect(branch_1.first.to_s).to eq 'e'
80
- expect(branch_1.first.conditional_level).to eq 3
81
-
82
- expect(branch_2).to be_a Conditional::Branch
83
- expect(branch_2.to_s).to eq 'f'
84
- expect(branch_2.conditional_level).to eq 3
85
-
86
- expect(branch_2.first.to_s).to eq 'f'
87
- expect(branch_2.first.conditional_level).to eq 3
88
- end
89
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe(Regexp::Expression::FreeSpace) do
4
- specify('white space quantify raises error') do
5
- regexp = /
6
- a # Comment
7
- /x
8
-
9
- root = RP.parse(regexp)
10
- space = root[0]
11
-
12
- expect(space).to be_instance_of(FreeSpace::WhiteSpace)
13
- expect { space.quantify(:dummy, '#') }.to raise_error(Regexp::Parser::Error)
14
- end
15
-
16
- specify('comment quantify raises error') do
17
- regexp = /
18
- a # Comment
19
- /x
20
-
21
- root = RP.parse(regexp)
22
- comment = root[3]
23
-
24
- expect(comment).to be_instance_of(FreeSpace::Comment)
25
- expect { comment.quantify(:dummy, '#') }.to raise_error(Regexp::Parser::Error)
26
- end
27
- end