ripper_ruby_parser 1.6.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/README.md +4 -23
  4. data/Rakefile +12 -12
  5. data/lib/ripper_ruby_parser.rb +2 -2
  6. data/lib/ripper_ruby_parser/commenting_ripper_parser.rb +9 -9
  7. data/lib/ripper_ruby_parser/parser.rb +3 -3
  8. data/lib/ripper_ruby_parser/sexp_handlers.rb +9 -9
  9. data/lib/ripper_ruby_parser/sexp_handlers/assignment.rb +3 -9
  10. data/lib/ripper_ruby_parser/sexp_handlers/blocks.rb +19 -24
  11. data/lib/ripper_ruby_parser/sexp_handlers/literals.rb +14 -18
  12. data/lib/ripper_ruby_parser/sexp_handlers/methods.rb +3 -3
  13. data/lib/ripper_ruby_parser/sexp_processor.rb +4 -4
  14. data/lib/ripper_ruby_parser/unescape.rb +11 -11
  15. data/lib/ripper_ruby_parser/version.rb +1 -1
  16. data/test/end_to_end/comments_test.rb +10 -10
  17. data/test/end_to_end/comparison_test.rb +28 -28
  18. data/test/end_to_end/lib_comparison_test.rb +6 -6
  19. data/test/end_to_end/line_numbering_test.rb +10 -10
  20. data/test/end_to_end/samples_comparison_test.rb +5 -5
  21. data/test/end_to_end/test_comparison_test.rb +6 -6
  22. data/test/pt_testcase/pt_test.rb +7 -7
  23. data/test/ripper_ruby_parser/commenting_ripper_parser_test.rb +163 -169
  24. data/test/ripper_ruby_parser/parser_test.rb +338 -338
  25. data/test/ripper_ruby_parser/sexp_handlers/assignment_test.rb +475 -511
  26. data/test/ripper_ruby_parser/sexp_handlers/blocks_test.rb +582 -564
  27. data/test/ripper_ruby_parser/sexp_handlers/conditionals_test.rb +469 -469
  28. data/test/ripper_ruby_parser/sexp_handlers/literals_test.rb +713 -724
  29. data/test/ripper_ruby_parser/sexp_handlers/loops_test.rb +155 -155
  30. data/test/ripper_ruby_parser/sexp_handlers/method_calls_test.rb +181 -181
  31. data/test/ripper_ruby_parser/sexp_handlers/methods_test.rb +337 -352
  32. data/test/ripper_ruby_parser/sexp_handlers/operators_test.rb +298 -298
  33. data/test/ripper_ruby_parser/sexp_processor_test.rb +119 -119
  34. data/test/ripper_ruby_parser/version_test.rb +2 -2
  35. data/test/samples/lambdas.rb +5 -0
  36. data/test/samples/misc.rb +3 -0
  37. data/test/samples/strings.rb +7 -0
  38. data/test/test_helper.rb +8 -6
  39. metadata +12 -10
@@ -1,398 +1,398 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require File.expand_path('../../test_helper.rb', File.dirname(__FILE__))
3
+ require File.expand_path("../../test_helper.rb", File.dirname(__FILE__))
4
4
 
5
5
  describe RipperRubyParser::Parser do
6
- describe '#parse' do
7
- describe 'for boolean operators' do
8
- it 'handles :and' do
9
- 'foo and bar'.
10
- must_be_parsed_as s(:and,
11
- s(:call, nil, :foo),
12
- s(:call, nil, :bar))
13
- end
14
-
15
- it 'handles double :and' do
16
- 'foo and bar and baz'.
17
- must_be_parsed_as s(:and,
18
- s(:call, nil, :foo),
19
- s(:and,
20
- s(:call, nil, :bar),
21
- s(:call, nil, :baz)))
22
- end
23
-
24
- it 'handles :or' do
25
- 'foo or bar'.
26
- must_be_parsed_as s(:or,
27
- s(:call, nil, :foo),
28
- s(:call, nil, :bar))
29
- end
30
-
31
- it 'handles double :or' do
32
- 'foo or bar or baz'.
33
- must_be_parsed_as s(:or,
34
- s(:call, nil, :foo),
35
- s(:or,
36
- s(:call, nil, :bar),
37
- s(:call, nil, :baz)))
38
- end
39
-
40
- it 'handles :or after :and' do
41
- 'foo and bar or baz'.
42
- must_be_parsed_as s(:or,
43
- s(:and,
44
- s(:call, nil, :foo),
45
- s(:call, nil, :bar)),
46
- s(:call, nil, :baz))
47
- end
48
-
49
- it 'handles :and after :or' do
50
- 'foo or bar and baz'.
51
- must_be_parsed_as s(:and,
52
- s(:or,
53
- s(:call, nil, :foo),
54
- s(:call, nil, :bar)),
55
- s(:call, nil, :baz))
56
- end
57
-
58
- it 'converts :&& to :and' do
59
- 'foo && bar'.
60
- must_be_parsed_as s(:and,
61
- s(:call, nil, :foo),
62
- s(:call, nil, :bar))
63
- end
64
-
65
- it 'handles :|| after :&&' do
66
- 'foo && bar || baz'.
67
- must_be_parsed_as s(:or,
68
- s(:and,
69
- s(:call, nil, :foo),
70
- s(:call, nil, :bar)),
71
- s(:call, nil, :baz))
72
- end
73
-
74
- it 'handles :&& after :||' do
75
- 'foo || bar && baz'.
76
- must_be_parsed_as s(:or,
77
- s(:call, nil, :foo),
78
- s(:and,
79
- s(:call, nil, :bar),
80
- s(:call, nil, :baz)))
81
- end
82
-
83
- it 'handles :|| with parentheses' do
84
- '(foo || bar) || baz'.
85
- must_be_parsed_as s(:or,
86
- s(:or,
87
- s(:call, nil, :foo),
88
- s(:call, nil, :bar)),
89
- s(:call, nil, :baz))
90
- end
91
-
92
- it 'handles nested :|| with parentheses' do
93
- 'foo || (bar || baz) || qux'.
94
- must_be_parsed_as s(:or,
6
+ describe "#parse" do
7
+ describe "for boolean operators" do
8
+ it "handles :and" do
9
+ _("foo and bar")
10
+ .must_be_parsed_as s(:and,
11
+ s(:call, nil, :foo),
12
+ s(:call, nil, :bar))
13
+ end
14
+
15
+ it "handles double :and" do
16
+ _("foo and bar and baz")
17
+ .must_be_parsed_as s(:and,
18
+ s(:call, nil, :foo),
19
+ s(:and,
20
+ s(:call, nil, :bar),
21
+ s(:call, nil, :baz)))
22
+ end
23
+
24
+ it "handles :or" do
25
+ _("foo or bar")
26
+ .must_be_parsed_as s(:or,
27
+ s(:call, nil, :foo),
28
+ s(:call, nil, :bar))
29
+ end
30
+
31
+ it "handles double :or" do
32
+ _("foo or bar or baz")
33
+ .must_be_parsed_as s(:or,
34
+ s(:call, nil, :foo),
35
+ s(:or,
36
+ s(:call, nil, :bar),
37
+ s(:call, nil, :baz)))
38
+ end
39
+
40
+ it "handles :or after :and" do
41
+ _("foo and bar or baz")
42
+ .must_be_parsed_as s(:or,
43
+ s(:and,
44
+ s(:call, nil, :foo),
45
+ s(:call, nil, :bar)),
46
+ s(:call, nil, :baz))
47
+ end
48
+
49
+ it "handles :and after :or" do
50
+ _("foo or bar and baz")
51
+ .must_be_parsed_as s(:and,
52
+ s(:or,
53
+ s(:call, nil, :foo),
54
+ s(:call, nil, :bar)),
55
+ s(:call, nil, :baz))
56
+ end
57
+
58
+ it "converts :&& to :and" do
59
+ _("foo && bar")
60
+ .must_be_parsed_as s(:and,
61
+ s(:call, nil, :foo),
62
+ s(:call, nil, :bar))
63
+ end
64
+
65
+ it "handles :|| after :&&" do
66
+ _("foo && bar || baz")
67
+ .must_be_parsed_as s(:or,
68
+ s(:and,
69
+ s(:call, nil, :foo),
70
+ s(:call, nil, :bar)),
71
+ s(:call, nil, :baz))
72
+ end
73
+
74
+ it "handles :&& after :||" do
75
+ _("foo || bar && baz")
76
+ .must_be_parsed_as s(:or,
77
+ s(:call, nil, :foo),
78
+ s(:and,
79
+ s(:call, nil, :bar),
80
+ s(:call, nil, :baz)))
81
+ end
82
+
83
+ it "handles :|| with parentheses" do
84
+ _("(foo || bar) || baz")
85
+ .must_be_parsed_as s(:or,
86
+ s(:or,
87
+ s(:call, nil, :foo),
88
+ s(:call, nil, :bar)),
89
+ s(:call, nil, :baz))
90
+ end
91
+
92
+ it "handles nested :|| with parentheses" do
93
+ _("foo || (bar || baz) || qux")
94
+ .must_be_parsed_as s(:or,
95
95
  s(:call, nil, :foo),
96
96
  s(:or,
97
97
  s(:or, s(:call, nil, :bar), s(:call, nil, :baz)),
98
98
  s(:call, nil, :qux)))
99
99
  end
100
100
 
101
- it 'converts :|| to :or' do
102
- 'foo || bar'.
103
- must_be_parsed_as s(:or,
104
- s(:call, nil, :foo),
105
- s(:call, nil, :bar))
101
+ it "converts :|| to :or" do
102
+ _("foo || bar")
103
+ .must_be_parsed_as s(:or,
104
+ s(:call, nil, :foo),
105
+ s(:call, nil, :bar))
106
106
  end
107
107
 
108
- it 'handles triple :and' do
109
- 'foo and bar and baz and qux'.
110
- must_be_parsed_as s(:and,
111
- s(:call, nil, :foo),
112
- s(:and,
113
- s(:call, nil, :bar),
114
- s(:and,
115
- s(:call, nil, :baz),
116
- s(:call, nil, :qux))))
108
+ it "handles triple :and" do
109
+ _("foo and bar and baz and qux")
110
+ .must_be_parsed_as s(:and,
111
+ s(:call, nil, :foo),
112
+ s(:and,
113
+ s(:call, nil, :bar),
114
+ s(:and,
115
+ s(:call, nil, :baz),
116
+ s(:call, nil, :qux))))
117
117
  end
118
118
 
119
- it 'handles triple :&&' do
120
- 'foo && bar && baz && qux'.
121
- must_be_parsed_as s(:and,
122
- s(:call, nil, :foo),
123
- s(:and,
124
- s(:call, nil, :bar),
125
- s(:and,
126
- s(:call, nil, :baz),
127
- s(:call, nil, :qux))))
119
+ it "handles triple :&&" do
120
+ _("foo && bar && baz && qux")
121
+ .must_be_parsed_as s(:and,
122
+ s(:call, nil, :foo),
123
+ s(:and,
124
+ s(:call, nil, :bar),
125
+ s(:and,
126
+ s(:call, nil, :baz),
127
+ s(:call, nil, :qux))))
128
128
  end
129
129
 
130
- it 'handles :!=' do
131
- 'foo != bar'.
132
- must_be_parsed_as s(:call,
133
- s(:call, nil, :foo),
134
- :!=,
135
- s(:call, nil, :bar))
130
+ it "handles :!=" do
131
+ _("foo != bar")
132
+ .must_be_parsed_as s(:call,
133
+ s(:call, nil, :foo),
134
+ :!=,
135
+ s(:call, nil, :bar))
136
136
  end
137
137
 
138
- it 'keeps :begin for the first argument of a binary operator' do
139
- 'begin; bar; end + foo'.
140
- must_be_parsed_as s(:call,
141
- s(:begin, s(:call, nil, :bar)),
142
- :+,
143
- s(:call, nil, :foo))
138
+ it "keeps :begin for the first argument of a binary operator" do
139
+ _("begin; bar; end + foo")
140
+ .must_be_parsed_as s(:call,
141
+ s(:begin, s(:call, nil, :bar)),
142
+ :+,
143
+ s(:call, nil, :foo))
144
144
  end
145
145
 
146
- it 'keeps :begin for the second argument of a binary operator' do
147
- 'foo + begin; bar; end'.
148
- must_be_parsed_as s(:call,
149
- s(:call, nil, :foo),
150
- :+,
151
- s(:begin, s(:call, nil, :bar)))
146
+ it "keeps :begin for the second argument of a binary operator" do
147
+ _("foo + begin; bar; end")
148
+ .must_be_parsed_as s(:call,
149
+ s(:call, nil, :foo),
150
+ :+,
151
+ s(:begin, s(:call, nil, :bar)))
152
152
  end
153
153
 
154
- it 'does not keep :begin for the first argument of a boolean operator' do
155
- 'begin; bar; end and foo'.
156
- must_be_parsed_as s(:and,
157
- s(:call, nil, :bar),
158
- s(:call, nil, :foo))
154
+ it "does not keep :begin for the first argument of a boolean operator" do
155
+ _("begin; bar; end and foo")
156
+ .must_be_parsed_as s(:and,
157
+ s(:call, nil, :bar),
158
+ s(:call, nil, :foo))
159
159
  end
160
160
 
161
- it 'keeps :begin for the second argument of a boolean operator' do
162
- 'foo and begin; bar; end'.
163
- must_be_parsed_as s(:and,
164
- s(:call, nil, :foo),
165
- s(:begin, s(:call, nil, :bar)))
161
+ it "keeps :begin for the second argument of a boolean operator" do
162
+ _("foo and begin; bar; end")
163
+ .must_be_parsed_as s(:and,
164
+ s(:call, nil, :foo),
165
+ s(:begin, s(:call, nil, :bar)))
166
166
  end
167
167
 
168
- it 'does not keep :begin for the first argument of a shift operator' do
169
- 'begin; bar; end << foo'.
170
- must_be_parsed_as s(:call,
171
- s(:call, nil, :bar),
172
- :<<,
173
- s(:call, nil, :foo))
168
+ it "does not keep :begin for the first argument of a shift operator" do
169
+ _("begin; bar; end << foo")
170
+ .must_be_parsed_as s(:call,
171
+ s(:call, nil, :bar),
172
+ :<<,
173
+ s(:call, nil, :foo))
174
174
  end
175
175
 
176
- it 'does not keep :begin for the second argument of a shift operator' do
177
- 'foo >> begin; bar; end'.
178
- must_be_parsed_as s(:call,
179
- s(:call, nil, :foo),
180
- :>>,
181
- s(:call, nil, :bar))
176
+ it "does not keep :begin for the second argument of a shift operator" do
177
+ _("foo >> begin; bar; end")
178
+ .must_be_parsed_as s(:call,
179
+ s(:call, nil, :foo),
180
+ :>>,
181
+ s(:call, nil, :bar))
182
182
  end
183
183
  end
184
184
 
185
- describe 'for the range operator' do
186
- it 'handles positive number literals' do
187
- '1..2'.
188
- must_be_parsed_as s(:lit, 1..2)
185
+ describe "for the range operator" do
186
+ it "handles positive number literals" do
187
+ _("1..2")
188
+ .must_be_parsed_as s(:lit, 1..2)
189
189
  end
190
190
 
191
- it 'handles negative number literals' do
192
- '-1..-2'.
193
- must_be_parsed_as s(:lit, -1..-2)
191
+ it "handles negative number literals" do
192
+ _("-1..-2")
193
+ .must_be_parsed_as s(:lit, -1..-2)
194
194
  end
195
195
 
196
- it 'handles float literals' do
197
- '1.0..2.0'.
198
- must_be_parsed_as s(:dot2,
199
- s(:lit, 1.0),
200
- s(:lit, 2.0))
196
+ it "handles float literals" do
197
+ _("1.0..2.0")
198
+ .must_be_parsed_as s(:dot2,
199
+ s(:lit, 1.0),
200
+ s(:lit, 2.0))
201
201
  end
202
202
 
203
- it 'handles string literals' do
204
- "'a'..'z'".
205
- must_be_parsed_as s(:dot2,
206
- s(:str, 'a'),
207
- s(:str, 'z'))
203
+ it "handles string literals" do
204
+ _("'a'..'z'")
205
+ .must_be_parsed_as s(:dot2,
206
+ s(:str, "a"),
207
+ s(:str, "z"))
208
208
  end
209
209
 
210
- it 'handles non-literal begin' do
211
- 'foo..3'.
212
- must_be_parsed_as s(:dot2,
213
- s(:call, nil, :foo),
214
- s(:lit, 3))
210
+ it "handles non-literal begin" do
211
+ _("foo..3")
212
+ .must_be_parsed_as s(:dot2,
213
+ s(:call, nil, :foo),
214
+ s(:lit, 3))
215
215
  end
216
216
 
217
- it 'handles non-literal end' do
218
- '3..foo'.
219
- must_be_parsed_as s(:dot2,
220
- s(:lit, 3),
221
- s(:call, nil, :foo))
217
+ it "handles non-literal end" do
218
+ _("3..foo")
219
+ .must_be_parsed_as s(:dot2,
220
+ s(:lit, 3),
221
+ s(:call, nil, :foo))
222
222
  end
223
223
 
224
- it 'handles non-literals' do
225
- 'foo..bar'.
226
- must_be_parsed_as s(:dot2,
227
- s(:call, nil, :foo),
228
- s(:call, nil, :bar))
224
+ it "handles non-literals" do
225
+ _("foo..bar")
226
+ .must_be_parsed_as s(:dot2,
227
+ s(:call, nil, :foo),
228
+ s(:call, nil, :bar))
229
229
  end
230
230
  end
231
231
 
232
- describe 'for the exclusive range operator' do
233
- it 'handles positive number literals' do
234
- '1...2'.
235
- must_be_parsed_as s(:lit, 1...2)
232
+ describe "for the exclusive range operator" do
233
+ it "handles positive number literals" do
234
+ _("1...2")
235
+ .must_be_parsed_as s(:lit, 1...2)
236
236
  end
237
237
 
238
- it 'handles negative number literals' do
239
- '-1...-2'.
240
- must_be_parsed_as s(:lit, -1...-2)
238
+ it "handles negative number literals" do
239
+ _("-1...-2")
240
+ .must_be_parsed_as s(:lit, -1...-2)
241
241
  end
242
242
 
243
- it 'handles float literals' do
244
- '1.0...2.0'.
245
- must_be_parsed_as s(:dot3,
246
- s(:lit, 1.0),
247
- s(:lit, 2.0))
243
+ it "handles float literals" do
244
+ _("1.0...2.0")
245
+ .must_be_parsed_as s(:dot3,
246
+ s(:lit, 1.0),
247
+ s(:lit, 2.0))
248
248
  end
249
249
 
250
- it 'handles string literals' do
251
- "'a'...'z'".
252
- must_be_parsed_as s(:dot3,
253
- s(:str, 'a'),
254
- s(:str, 'z'))
250
+ it "handles string literals" do
251
+ _("'a'...'z'")
252
+ .must_be_parsed_as s(:dot3,
253
+ s(:str, "a"),
254
+ s(:str, "z"))
255
255
  end
256
256
 
257
- it 'handles non-literal begin' do
258
- 'foo...3'.
259
- must_be_parsed_as s(:dot3,
260
- s(:call, nil, :foo),
261
- s(:lit, 3))
257
+ it "handles non-literal begin" do
258
+ _("foo...3")
259
+ .must_be_parsed_as s(:dot3,
260
+ s(:call, nil, :foo),
261
+ s(:lit, 3))
262
262
  end
263
263
 
264
- it 'handles non-literal end' do
265
- '3...foo'.
266
- must_be_parsed_as s(:dot3,
267
- s(:lit, 3),
268
- s(:call, nil, :foo))
264
+ it "handles non-literal end" do
265
+ _("3...foo")
266
+ .must_be_parsed_as s(:dot3,
267
+ s(:lit, 3),
268
+ s(:call, nil, :foo))
269
269
  end
270
270
 
271
- it 'handles two non-literals' do
272
- 'foo...bar'.
273
- must_be_parsed_as s(:dot3,
274
- s(:call, nil, :foo),
275
- s(:call, nil, :bar))
271
+ it "handles two non-literals" do
272
+ _("foo...bar")
273
+ .must_be_parsed_as s(:dot3,
274
+ s(:call, nil, :foo),
275
+ s(:call, nil, :bar))
276
276
  end
277
277
  end
278
278
 
279
- describe 'for unary operators' do
280
- it 'handles unary minus with an integer literal' do
281
- '- 1'.must_be_parsed_as s(:call, s(:lit, 1), :-@)
279
+ describe "for unary operators" do
280
+ it "handles unary minus with an integer literal" do
281
+ _("- 1").must_be_parsed_as s(:call, s(:lit, 1), :-@)
282
282
  end
283
283
 
284
- it 'handles unary minus with a float literal' do
285
- '- 3.14'.must_be_parsed_as s(:call, s(:lit, 3.14), :-@)
284
+ it "handles unary minus with a float literal" do
285
+ _("- 3.14").must_be_parsed_as s(:call, s(:lit, 3.14), :-@)
286
286
  end
287
287
 
288
- it 'handles unary minus with a non-literal' do
289
- '-foo'.
290
- must_be_parsed_as s(:call,
291
- s(:call, nil, :foo),
292
- :-@)
288
+ it "handles unary minus with a non-literal" do
289
+ _("-foo")
290
+ .must_be_parsed_as s(:call,
291
+ s(:call, nil, :foo),
292
+ :-@)
293
293
  end
294
294
 
295
- it 'handles unary minus with a negative number literal' do
296
- '- -1'.must_be_parsed_as s(:call, s(:lit, -1), :-@)
295
+ it "handles unary minus with a negative number literal" do
296
+ _("- -1").must_be_parsed_as s(:call, s(:lit, -1), :-@)
297
297
  end
298
298
 
299
- it 'handles unary plus with a number literal' do
300
- '+ 1'.must_be_parsed_as s(:call, s(:lit, 1), :+@)
299
+ it "handles unary plus with a number literal" do
300
+ _("+ 1").must_be_parsed_as s(:call, s(:lit, 1), :+@)
301
301
  end
302
302
 
303
- it 'handles unary plus with a non-literal' do
304
- '+foo'.
305
- must_be_parsed_as s(:call,
306
- s(:call, nil, :foo),
307
- :+@)
303
+ it "handles unary plus with a non-literal" do
304
+ _("+foo")
305
+ .must_be_parsed_as s(:call,
306
+ s(:call, nil, :foo),
307
+ :+@)
308
308
  end
309
309
 
310
- it 'handles unary !' do
311
- '!foo'.
312
- must_be_parsed_as s(:call, s(:call, nil, :foo), :!)
310
+ it "handles unary !" do
311
+ _("!foo")
312
+ .must_be_parsed_as s(:call, s(:call, nil, :foo), :!)
313
313
  end
314
314
 
315
- it 'converts :not to :!' do
316
- 'not foo'.
317
- must_be_parsed_as s(:call, s(:call, nil, :foo), :!)
315
+ it "converts :not to :!" do
316
+ _("not foo")
317
+ .must_be_parsed_as s(:call, s(:call, nil, :foo), :!)
318
318
  end
319
319
 
320
- it 'handles unary ! with a number literal' do
321
- '!1'.
322
- must_be_parsed_as s(:call, s(:lit, 1), :!)
320
+ it "handles unary ! with a number literal" do
321
+ _("!1")
322
+ .must_be_parsed_as s(:call, s(:lit, 1), :!)
323
323
  end
324
324
 
325
- it 'keeps :begin for the argument' do
326
- '- begin; foo; end'.
327
- must_be_parsed_as s(:call,
328
- s(:begin, s(:call, nil, :foo)),
329
- :-@)
325
+ it "keeps :begin for the argument" do
326
+ _("- begin; foo; end")
327
+ .must_be_parsed_as s(:call,
328
+ s(:begin, s(:call, nil, :foo)),
329
+ :-@)
330
330
  end
331
331
  end
332
332
 
333
- describe 'for the ternary operater' do
334
- it 'works in the simple case' do
335
- 'foo ? bar : baz'.
336
- must_be_parsed_as s(:if,
337
- s(:call, nil, :foo),
338
- s(:call, nil, :bar),
339
- s(:call, nil, :baz))
333
+ describe "for the ternary operater" do
334
+ it "works in the simple case" do
335
+ _("foo ? bar : baz")
336
+ .must_be_parsed_as s(:if,
337
+ s(:call, nil, :foo),
338
+ s(:call, nil, :bar),
339
+ s(:call, nil, :baz))
340
340
  end
341
341
 
342
- it 'keeps :begin for the first argument' do
343
- 'begin; foo; end ? bar : baz'.
344
- must_be_parsed_as s(:if,
345
- s(:begin, s(:call, nil, :foo)),
346
- s(:call, nil, :bar),
347
- s(:call, nil, :baz))
342
+ it "keeps :begin for the first argument" do
343
+ _("begin; foo; end ? bar : baz")
344
+ .must_be_parsed_as s(:if,
345
+ s(:begin, s(:call, nil, :foo)),
346
+ s(:call, nil, :bar),
347
+ s(:call, nil, :baz))
348
348
  end
349
349
 
350
- it 'keeps :begin for the second argument' do
351
- 'foo ? begin; bar; end : baz'.
352
- must_be_parsed_as s(:if,
353
- s(:call, nil, :foo),
354
- s(:begin, s(:call, nil, :bar)),
355
- s(:call, nil, :baz))
350
+ it "keeps :begin for the second argument" do
351
+ _("foo ? begin; bar; end : baz")
352
+ .must_be_parsed_as s(:if,
353
+ s(:call, nil, :foo),
354
+ s(:begin, s(:call, nil, :bar)),
355
+ s(:call, nil, :baz))
356
356
  end
357
357
 
358
- it 'keeps :begin for the third argument' do
359
- 'foo ? bar : begin; baz; end'.
360
- must_be_parsed_as s(:if,
361
- s(:call, nil, :foo),
362
- s(:call, nil, :bar),
363
- s(:begin, s(:call, nil, :baz)))
358
+ it "keeps :begin for the third argument" do
359
+ _("foo ? bar : begin; baz; end")
360
+ .must_be_parsed_as s(:if,
361
+ s(:call, nil, :foo),
362
+ s(:call, nil, :bar),
363
+ s(:begin, s(:call, nil, :baz)))
364
364
  end
365
365
  end
366
366
 
367
- describe 'for match operators' do
368
- it 'handles :=~ with two non-literals' do
369
- 'foo =~ bar'.
370
- must_be_parsed_as s(:call,
371
- s(:call, nil, :foo),
372
- :=~,
373
- s(:call, nil, :bar))
367
+ describe "for match operators" do
368
+ it "handles :=~ with two non-literals" do
369
+ _("foo =~ bar")
370
+ .must_be_parsed_as s(:call,
371
+ s(:call, nil, :foo),
372
+ :=~,
373
+ s(:call, nil, :bar))
374
374
  end
375
375
 
376
- it 'handles :=~ with literal regexp on the left hand side' do
377
- '/foo/ =~ bar'.
378
- must_be_parsed_as s(:match2,
379
- s(:lit, /foo/),
380
- s(:call, nil, :bar))
376
+ it "handles :=~ with literal regexp on the left hand side" do
377
+ _("/foo/ =~ bar")
378
+ .must_be_parsed_as s(:match2,
379
+ s(:lit, /foo/),
380
+ s(:call, nil, :bar))
381
381
  end
382
382
 
383
- it 'handles :=~ with literal regexp on the right hand side' do
384
- 'foo =~ /bar/'.
385
- must_be_parsed_as s(:match3,
386
- s(:lit, /bar/),
387
- s(:call, nil, :foo))
383
+ it "handles :=~ with literal regexp on the right hand side" do
384
+ _("foo =~ /bar/")
385
+ .must_be_parsed_as s(:match3,
386
+ s(:lit, /bar/),
387
+ s(:call, nil, :foo))
388
388
  end
389
389
 
390
- it 'handles negated match operators' do
391
- 'foo !~ bar'.must_be_parsed_as s(:not,
392
- s(:call,
393
- s(:call, nil, :foo),
394
- :=~,
395
- s(:call, nil, :bar)))
390
+ it "handles negated match operators" do
391
+ _("foo !~ bar").must_be_parsed_as s(:not,
392
+ s(:call,
393
+ s(:call, nil, :foo),
394
+ :=~,
395
+ s(:call, nil, :bar)))
396
396
  end
397
397
  end
398
398
  end