ripper_ruby_parser 1.1.1 → 1.1.2

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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +19 -0
  3. data/Rakefile +2 -2
  4. data/lib/ripper_ruby_parser/commenting_ripper_parser.rb +55 -4
  5. data/lib/ripper_ruby_parser/sexp_handlers/blocks.rb +20 -13
  6. data/lib/ripper_ruby_parser/sexp_handlers/conditionals.rb +27 -12
  7. data/lib/ripper_ruby_parser/sexp_handlers/hashes.rb +25 -12
  8. data/lib/ripper_ruby_parser/sexp_handlers/helper_methods.rb +4 -2
  9. data/lib/ripper_ruby_parser/sexp_handlers/literals.rb +19 -15
  10. data/lib/ripper_ruby_parser/sexp_handlers/loops.rb +25 -11
  11. data/lib/ripper_ruby_parser/sexp_handlers/method_calls.rb +12 -4
  12. data/lib/ripper_ruby_parser/sexp_handlers/methods.rb +8 -4
  13. data/lib/ripper_ruby_parser/sexp_handlers/operators.rb +1 -5
  14. data/lib/ripper_ruby_parser/version.rb +1 -1
  15. data/lib/ripper_ruby_parser.rb +2 -2
  16. data/test/end_to_end/comments_test.rb +4 -4
  17. data/test/end_to_end/comparison_test.rb +15 -15
  18. data/test/end_to_end/error_conditions_test.rb +16 -16
  19. data/test/end_to_end/lib_comparison_test.rb +3 -3
  20. data/test/end_to_end/line_numbering_test.rb +4 -4
  21. data/test/end_to_end/samples_comparison_test.rb +4 -4
  22. data/test/end_to_end/test_comparison_test.rb +3 -3
  23. data/test/pt_testcase/pt_test.rb +4 -4
  24. data/test/test_helper.rb +1 -1
  25. data/test/unit/commenting_ripper_parser_test.rb +33 -33
  26. data/test/unit/parser_assignment_test.rb +30 -30
  27. data/test/unit/parser_blocks_test.rb +83 -65
  28. data/test/unit/parser_conditionals_test.rb +96 -64
  29. data/test/unit/parser_literals_test.rb +308 -212
  30. data/test/unit/parser_loops_test.rb +85 -15
  31. data/test/unit/parser_method_calls_test.rb +100 -41
  32. data/test/unit/parser_operators_test.rb +60 -28
  33. data/test/unit/parser_test.rb +435 -410
  34. data/test/unit/sexp_processor_test.rb +82 -82
  35. data/test/unit/version_test.rb +1 -1
  36. metadata +2 -2
@@ -2,248 +2,216 @@ require File.expand_path('../test_helper.rb', File.dirname(__FILE__))
2
2
 
3
3
  describe RipperRubyParser::Parser do
4
4
  let(:parser) { RipperRubyParser::Parser.new }
5
- describe "#parse" do
6
- it "returns an s-expression" do
7
- result = parser.parse "foo"
5
+ describe '#parse' do
6
+ it 'returns an s-expression' do
7
+ result = parser.parse 'foo'
8
8
  result.must_be_instance_of Sexp
9
9
  end
10
10
 
11
- it "post-processes its result with the passed sexp processor" do
11
+ it 'post-processes its result with the passed sexp processor' do
12
12
  sexp_p = MiniTest::Mock.new
13
13
  sexp_p.expect :process, s(:result), [Sexp]
14
14
  sexp_p.expect :filename=, nil, ['(string)']
15
15
  sexp_p.expect :extra_compatible=, nil, [false]
16
16
 
17
17
  parser = RipperRubyParser::Parser.new sexp_p
18
- result = parser.parse "any code"
18
+ result = parser.parse 'any code'
19
19
 
20
20
  result.must_equal s(:result)
21
21
  sexp_p.verify
22
22
  end
23
23
 
24
- describe "for an empty program" do
25
- it "returns nil" do
26
- "".must_be_parsed_as nil
24
+ describe 'for an empty program' do
25
+ it 'returns nil' do
26
+ ''.must_be_parsed_as nil
27
27
  end
28
28
  end
29
29
 
30
- describe "for a class declaration" do
31
- it "works with a namespaced class name" do
32
- "class Foo::Bar; end".
30
+ describe 'for a class declaration' do
31
+ it 'works with a namespaced class name' do
32
+ 'class Foo::Bar; end'.
33
33
  must_be_parsed_as s(:class,
34
34
  s(:colon2, s(:const, :Foo), :Bar),
35
35
  nil)
36
36
  end
37
37
 
38
- it "works for singleton classes" do
39
- "class << self; end".must_be_parsed_as s(:sclass, s(:self))
38
+ it 'works for singleton classes' do
39
+ 'class << self; end'.must_be_parsed_as s(:sclass, s(:self))
40
40
  end
41
41
  end
42
42
 
43
- describe "for a module declaration" do
44
- it "works with a namespaced module name" do
45
- "module Foo::Bar; end".
43
+ describe 'for a module declaration' do
44
+ it 'works with a namespaced module name' do
45
+ 'module Foo::Bar; end'.
46
46
  must_be_parsed_as s(:module,
47
47
  s(:colon2, s(:const, :Foo), :Bar))
48
48
  end
49
49
  end
50
50
 
51
- describe "for empty brackets" do
52
- it "works with lone ()" do
53
- "()".must_be_parsed_as s(:nil)
51
+ describe 'for empty brackets' do
52
+ it 'works with lone ()' do
53
+ '()'.must_be_parsed_as s(:nil)
54
54
  end
55
55
  end
56
56
 
57
- describe "for the return statement" do
58
- it "works with no arguments" do
59
- "return".
57
+ describe 'for the return statement' do
58
+ it 'works with no arguments' do
59
+ 'return'.
60
60
  must_be_parsed_as s(:return)
61
61
  end
62
62
 
63
- it "works with one argument" do
64
- "return foo".
63
+ it 'works with one argument' do
64
+ 'return foo'.
65
65
  must_be_parsed_as s(:return,
66
66
  s(:call, nil, :foo))
67
67
  end
68
68
 
69
- it "works with a splat argument" do
70
- "return *foo".
69
+ it 'works with a splat argument' do
70
+ 'return *foo'.
71
71
  must_be_parsed_as s(:return,
72
72
  s(:svalue,
73
73
  s(:splat,
74
74
  s(:call, nil, :foo))))
75
75
  end
76
76
 
77
- it "works with multiple arguments" do
78
- "return foo, bar".
77
+ it 'works with multiple arguments' do
78
+ 'return foo, bar'.
79
79
  must_be_parsed_as s(:return,
80
80
  s(:array,
81
81
  s(:call, nil, :foo),
82
82
  s(:call, nil, :bar)))
83
83
  end
84
84
 
85
- it "works with a regular argument and a splat argument" do
86
- "return foo, *bar".
85
+ it 'works with a regular argument and a splat argument' do
86
+ 'return foo, *bar'.
87
87
  must_be_parsed_as s(:return,
88
88
  s(:array,
89
89
  s(:call, nil, :foo),
90
90
  s(:splat,
91
91
  s(:call, nil, :bar))))
92
92
  end
93
- end
94
-
95
- describe "for the until statement" do
96
- it "works in the prefix block case with do" do
97
- "until foo do; bar; end".
98
- must_be_parsed_as s(:until,
99
- s(:call, nil, :foo),
100
- s(:call, nil, :bar), true)
101
- end
102
-
103
- it "works in the prefix block case without do" do
104
- "until foo; bar; end".
105
- must_be_parsed_as s(:until,
106
- s(:call, nil, :foo),
107
- s(:call, nil, :bar), true)
108
- end
109
-
110
- it "works in the single-line postfix case" do
111
- "foo until bar".
112
- must_be_parsed_as s(:until,
113
- s(:call, nil, :bar),
114
- s(:call, nil, :foo), true)
115
- end
116
-
117
- it "works in the block postfix case" do
118
- "begin; foo; end until bar".
119
- must_be_parsed_as s(:until,
120
- s(:call, nil, :bar),
121
- s(:call, nil, :foo), false)
122
- end
123
- end
124
93
 
125
- describe "for the while statement" do
126
- it "works with do" do
127
- "while foo do; bar; end".
128
- must_be_parsed_as s(:while,
129
- s(:call, nil, :foo),
130
- s(:call, nil, :bar), true)
94
+ it 'works with a function call with parentheses' do
95
+ 'return foo(bar)'.
96
+ must_be_parsed_as s(:return,
97
+ s(:call, nil, :foo,
98
+ s(:call, nil, :bar)))
131
99
  end
132
100
 
133
- it "works without do" do
134
- "while foo; bar; end".
135
- must_be_parsed_as s(:while,
136
- s(:call, nil, :foo),
137
- s(:call, nil, :bar), true)
101
+ it 'works with a function call without parentheses' do
102
+ 'return foo bar'.
103
+ must_be_parsed_as s(:return,
104
+ s(:call, nil, :foo,
105
+ s(:call, nil, :bar)))
138
106
  end
139
107
  end
140
108
 
141
- describe "for the for statement" do
142
- it "works with do" do
143
- "for foo in bar do; baz; end".
109
+ describe 'for the for statement' do
110
+ it 'works with do' do
111
+ 'for foo in bar do; baz; end'.
144
112
  must_be_parsed_as s(:for,
145
113
  s(:call, nil, :bar),
146
114
  s(:lasgn, :foo),
147
115
  s(:call, nil, :baz))
148
116
  end
149
117
 
150
- it "works without do" do
151
- "for foo in bar; baz; end".
118
+ it 'works without do' do
119
+ 'for foo in bar; baz; end'.
152
120
  must_be_parsed_as s(:for,
153
121
  s(:call, nil, :bar),
154
122
  s(:lasgn, :foo),
155
123
  s(:call, nil, :baz))
156
124
  end
157
125
 
158
- it "works with an empty body" do
159
- "for foo in bar; end".
126
+ it 'works with an empty body' do
127
+ 'for foo in bar; end'.
160
128
  must_be_parsed_as s(:for,
161
129
  s(:call, nil, :bar),
162
130
  s(:lasgn, :foo))
163
131
  end
164
132
  end
165
133
 
166
- describe "for a begin..end block" do
167
- it "works with no statements" do
168
- "begin; end".
134
+ describe 'for a begin..end block' do
135
+ it 'works with no statements' do
136
+ 'begin; end'.
169
137
  must_be_parsed_as s(:nil)
170
138
  end
171
139
 
172
- it "works with one statement" do
173
- "begin; foo; end".
140
+ it 'works with one statement' do
141
+ 'begin; foo; end'.
174
142
  must_be_parsed_as s(:call, nil, :foo)
175
143
  end
176
144
 
177
- it "works with multiple statements" do
178
- "begin; foo; bar; end".
145
+ it 'works with multiple statements' do
146
+ 'begin; foo; bar; end'.
179
147
  must_be_parsed_as s(:block,
180
148
  s(:call, nil, :foo),
181
149
  s(:call, nil, :bar))
182
150
  end
183
151
  end
184
152
 
185
- describe "for the undef statement" do
186
- it "works with a single bareword identifier" do
187
- "undef foo".
153
+ describe 'for the undef statement' do
154
+ it 'works with a single bareword identifier' do
155
+ 'undef foo'.
188
156
  must_be_parsed_as s(:undef, s(:lit, :foo))
189
157
  end
190
158
 
191
- it "works with a single symbol" do
192
- "undef :foo".
159
+ it 'works with a single symbol' do
160
+ 'undef :foo'.
193
161
  must_be_parsed_as s(:undef, s(:lit, :foo))
194
162
  end
195
163
 
196
- it "works with multiple bareword identifiers" do
197
- "undef foo, bar".
164
+ it 'works with multiple bareword identifiers' do
165
+ 'undef foo, bar'.
198
166
  must_be_parsed_as s(:block,
199
167
  s(:undef, s(:lit, :foo)),
200
168
  s(:undef, s(:lit, :bar)))
201
169
  end
202
170
 
203
- it "works with multiple bareword symbols" do
204
- "undef :foo, :bar".
171
+ it 'works with multiple bareword symbols' do
172
+ 'undef :foo, :bar'.
205
173
  must_be_parsed_as s(:block,
206
174
  s(:undef, s(:lit, :foo)),
207
175
  s(:undef, s(:lit, :bar)))
208
176
  end
209
177
  end
210
178
 
211
- describe "for the alias statement" do
212
- it "works with regular barewords" do
213
- "alias foo bar".
179
+ describe 'for the alias statement' do
180
+ it 'works with regular barewords' do
181
+ 'alias foo bar'.
214
182
  must_be_parsed_as s(:alias,
215
183
  s(:lit, :foo), s(:lit, :bar))
216
184
  end
217
185
 
218
- it "works with symbols" do
219
- "alias :foo :bar".
186
+ it 'works with symbols' do
187
+ 'alias :foo :bar'.
220
188
  must_be_parsed_as s(:alias,
221
189
  s(:lit, :foo), s(:lit, :bar))
222
190
  end
223
191
 
224
- it "works with operator barewords" do
225
- "alias + -".
192
+ it 'works with operator barewords' do
193
+ 'alias + -'.
226
194
  must_be_parsed_as s(:alias,
227
195
  s(:lit, :+), s(:lit, :-))
228
196
  end
229
197
 
230
- it "works with global variables" do
231
- "alias $foo $bar".
198
+ it 'works with global variables' do
199
+ 'alias $foo $bar'.
232
200
  must_be_parsed_as s(:valias, :$foo, :$bar)
233
201
  end
234
202
  end
235
203
 
236
- describe "for arguments" do
237
- it "works for a simple case with splat" do
238
- "foo *bar".
204
+ describe 'for arguments' do
205
+ it 'works for a simple case with splat' do
206
+ 'foo *bar'.
239
207
  must_be_parsed_as s(:call,
240
208
  nil,
241
209
  :foo,
242
210
  s(:splat, s(:call, nil, :bar)))
243
211
  end
244
212
 
245
- it "works for a multi-argument case with splat" do
246
- "foo bar, *baz".
213
+ it 'works for a multi-argument case with splat' do
214
+ 'foo bar, *baz'.
247
215
  must_be_parsed_as s(:call,
248
216
  nil,
249
217
  :foo,
@@ -251,15 +219,15 @@ describe RipperRubyParser::Parser do
251
219
  s(:splat, s(:call, nil, :baz)))
252
220
  end
253
221
 
254
- it "works for a simple case passing a block" do
255
- "foo &bar".
222
+ it 'works for a simple case passing a block' do
223
+ 'foo &bar'.
256
224
  must_be_parsed_as s(:call, nil, :foo,
257
225
  s(:block_pass,
258
226
  s(:call, nil, :bar)))
259
227
  end
260
228
 
261
- it "works for a bare hash" do
262
- "foo bar => baz".
229
+ it 'works for a bare hash' do
230
+ 'foo bar => baz'.
263
231
  must_be_parsed_as s(:call, nil, :foo,
264
232
  s(:hash,
265
233
  s(:call, nil, :bar),
@@ -267,29 +235,29 @@ describe RipperRubyParser::Parser do
267
235
  end
268
236
  end
269
237
 
270
- describe "for collection indexing" do
271
- it "works in the simple case" do
272
- "foo[bar]".
238
+ describe 'for collection indexing' do
239
+ it 'works in the simple case' do
240
+ 'foo[bar]'.
273
241
  must_be_parsed_as s(:call,
274
242
  s(:call, nil, :foo),
275
243
  :[],
276
244
  s(:call, nil, :bar))
277
245
  end
278
246
 
279
- it "works without any indexes" do
280
- "foo[]".must_be_parsed_as s(:call, s(:call, nil, :foo),
247
+ it 'works without any indexes' do
248
+ 'foo[]'.must_be_parsed_as s(:call, s(:call, nil, :foo),
281
249
  :[])
282
250
  end
283
251
 
284
- it "drops self from self[]" do
285
- "self[foo]".must_be_parsed_as s(:call, nil, :[],
252
+ it 'drops self from self[]' do
253
+ 'self[foo]'.must_be_parsed_as s(:call, nil, :[],
286
254
  s(:call, nil, :foo))
287
255
  end
288
256
  end
289
257
 
290
- describe "for method definitions" do
291
- it "works with def with receiver" do
292
- "def foo.bar; end".
258
+ describe 'for method definitions' do
259
+ it 'works with def with receiver' do
260
+ 'def foo.bar; end'.
293
261
  must_be_parsed_as s(:defs,
294
262
  s(:call, nil, :foo),
295
263
  :bar,
@@ -297,8 +265,8 @@ describe RipperRubyParser::Parser do
297
265
  s(:nil))
298
266
  end
299
267
 
300
- it "works with def with receiver and multiple statements" do
301
- "def foo.bar; baz; qux; end".
268
+ it 'works with def with receiver and multiple statements' do
269
+ 'def foo.bar; baz; qux; end'.
302
270
  must_be_parsed_as s(:defs,
303
271
  s(:call, nil, :foo),
304
272
  :bar,
@@ -307,16 +275,16 @@ describe RipperRubyParser::Parser do
307
275
  s(:call, nil, :qux))
308
276
  end
309
277
 
310
- it "works with a method argument with a default value" do
311
- "def foo bar=nil; end".
278
+ it 'works with a method argument with a default value' do
279
+ 'def foo bar=nil; end'.
312
280
  must_be_parsed_as s(:defn,
313
281
  :foo,
314
282
  s(:args, s(:lasgn, :bar, s(:nil))),
315
283
  s(:nil))
316
284
  end
317
285
 
318
- it "works with several method arguments with default values" do
319
- "def foo bar=1, baz=2; end".
286
+ it 'works with several method arguments with default values' do
287
+ 'def foo bar=1, baz=2; end'.
320
288
  must_be_parsed_as s(:defn,
321
289
  :foo,
322
290
  s(:args,
@@ -325,47 +293,47 @@ describe RipperRubyParser::Parser do
325
293
  s(:nil))
326
294
  end
327
295
 
328
- it "works with brackets around the parameter list" do
329
- "def foo(bar); end".
296
+ it 'works with brackets around the parameter list' do
297
+ 'def foo(bar); end'.
330
298
  must_be_parsed_as s(:defn, :foo, s(:args, :bar), s(:nil))
331
299
  end
332
300
 
333
- it "works with a simple splat" do
334
- "def foo *bar; end".
301
+ it 'works with a simple splat' do
302
+ 'def foo *bar; end'.
335
303
  must_be_parsed_as s(:defn, :foo, s(:args, :"*bar"), s(:nil))
336
304
  end
337
305
 
338
- it "works with a regular argument plus splat" do
339
- "def foo bar, *baz; end".
306
+ it 'works with a regular argument plus splat' do
307
+ 'def foo bar, *baz; end'.
340
308
  must_be_parsed_as s(:defn, :foo, s(:args, :bar, :"*baz"), s(:nil))
341
309
  end
342
310
 
343
- it "works with a nameless splat" do
344
- "def foo *; end".
311
+ it 'works with a nameless splat' do
312
+ 'def foo *; end'.
345
313
  must_be_parsed_as s(:defn,
346
314
  :foo,
347
315
  s(:args, :"*"),
348
316
  s(:nil))
349
317
  end
350
318
 
351
- it "works for a simple case with explicit block parameter" do
352
- "def foo &bar; end".
319
+ it 'works for a simple case with explicit block parameter' do
320
+ 'def foo &bar; end'.
353
321
  must_be_parsed_as s(:defn,
354
322
  :foo,
355
323
  s(:args, :"&bar"),
356
324
  s(:nil))
357
325
  end
358
326
 
359
- it "works with a regular argument plus explicit block parameter" do
360
- "def foo bar, &baz; end".
327
+ it 'works with a regular argument plus explicit block parameter' do
328
+ 'def foo bar, &baz; end'.
361
329
  must_be_parsed_as s(:defn,
362
330
  :foo,
363
331
  s(:args, :bar, :"&baz"),
364
332
  s(:nil))
365
333
  end
366
334
 
367
- it "works with a default value plus explicit block parameter" do
368
- "def foo bar=1, &baz; end".
335
+ it 'works with a default value plus explicit block parameter' do
336
+ 'def foo bar=1, &baz; end'.
369
337
  must_be_parsed_as s(:defn,
370
338
  :foo,
371
339
  s(:args,
@@ -374,8 +342,8 @@ describe RipperRubyParser::Parser do
374
342
  s(:nil))
375
343
  end
376
344
 
377
- it "works with a default value plus mandatory argument" do
378
- "def foo bar=1, baz; end".
345
+ it 'works with a default value plus mandatory argument' do
346
+ 'def foo bar=1, baz; end'.
379
347
  must_be_parsed_as s(:defn,
380
348
  :foo,
381
349
  s(:args,
@@ -384,16 +352,16 @@ describe RipperRubyParser::Parser do
384
352
  s(:nil))
385
353
  end
386
354
 
387
- it "works with a splat plus explicit block parameter" do
388
- "def foo *bar, &baz; end".
355
+ it 'works with a splat plus explicit block parameter' do
356
+ 'def foo *bar, &baz; end'.
389
357
  must_be_parsed_as s(:defn,
390
358
  :foo,
391
359
  s(:args, :"*bar", :"&baz"),
392
360
  s(:nil))
393
361
  end
394
362
 
395
- it "works with a default value plus splat" do
396
- "def foo bar=1, *baz; end".
363
+ it 'works with a default value plus splat' do
364
+ 'def foo bar=1, *baz; end'.
397
365
  must_be_parsed_as s(:defn,
398
366
  :foo,
399
367
  s(:args,
@@ -402,8 +370,8 @@ describe RipperRubyParser::Parser do
402
370
  s(:nil))
403
371
  end
404
372
 
405
- it "works with a default value, splat, plus final mandatory arguments" do
406
- "def foo bar=1, *baz, qux, quuz; end".
373
+ it 'works with a default value, splat, plus final mandatory arguments' do
374
+ 'def foo bar=1, *baz, qux, quuz; end'.
407
375
  must_be_parsed_as s(:defn,
408
376
  :foo,
409
377
  s(:args,
@@ -412,39 +380,66 @@ describe RipperRubyParser::Parser do
412
380
  s(:nil))
413
381
  end
414
382
 
415
- it "works when the method name is an operator" do
416
- "def +; end".
383
+ it 'works with a named argument with a default value' do
384
+ 'def foo bar: 1; end'.
385
+ must_be_parsed_as s(:defn,
386
+ :foo,
387
+ s(:args,
388
+ s(:kwarg, :bar, s(:lit, 1))),
389
+ s(:nil))
390
+ end
391
+
392
+ it 'works with a named argument with no default value' do
393
+ skip 'Default values are required in Ruby 2.0' if RUBY_VERSION < '2.1.0'
394
+ 'def foo bar:; end'.
395
+ must_be_parsed_as s(:defn,
396
+ :foo,
397
+ s(:args,
398
+ s(:kwarg, :bar)),
399
+ s(:nil))
400
+ end
401
+
402
+ it 'works with a double splat' do
403
+ 'def foo **bar; end'.
404
+ must_be_parsed_as s(:defn,
405
+ :foo,
406
+ s(:args, :'**bar'),
407
+ s(:nil))
408
+ end
409
+
410
+ it 'works when the method name is an operator' do
411
+ 'def +; end'.
417
412
  must_be_parsed_as s(:defn, :+, s(:args),
418
413
  s(:nil))
419
414
  end
420
415
  end
421
416
 
422
- describe "for blocks" do
423
- it "works with no statements in the block body" do
424
- "foo do; end".
417
+ describe 'for blocks' do
418
+ it 'works with no statements in the block body' do
419
+ 'foo do; end'.
425
420
  must_be_parsed_as s(:iter,
426
421
  s(:call, nil, :foo),
427
422
  0)
428
423
  end
429
424
 
430
- it "works with next with no arguments" do
431
- "foo do; next; end".
425
+ it 'works with next with no arguments' do
426
+ 'foo do; next; end'.
432
427
  must_be_parsed_as s(:iter,
433
428
  s(:call, nil, :foo),
434
429
  0,
435
430
  s(:next))
436
431
  end
437
432
 
438
- it "works with next with one argument" do
439
- "foo do; next bar; end".
433
+ it 'works with next with one argument' do
434
+ 'foo do; next bar; end'.
440
435
  must_be_parsed_as s(:iter,
441
436
  s(:call, nil, :foo),
442
437
  0,
443
438
  s(:next, s(:call, nil, :bar)))
444
439
  end
445
440
 
446
- it "works with next with several arguments" do
447
- "foo do; next bar, baz; end".
441
+ it 'works with next with several arguments' do
442
+ 'foo do; next bar, baz; end'.
448
443
  must_be_parsed_as s(:iter,
449
444
  s(:call, nil, :foo),
450
445
  0,
@@ -454,24 +449,44 @@ describe RipperRubyParser::Parser do
454
449
  s(:call, nil, :baz))))
455
450
  end
456
451
 
457
- it "works with break with no arguments" do
458
- "foo do; break; end".
452
+ it 'works with next with a function call with parentheses' do
453
+ 'foo do; next foo(bar); end'.
454
+ must_be_parsed_as s(:iter,
455
+ s(:call, nil, :foo),
456
+ 0,
457
+ s(:next,
458
+ s(:call, nil, :foo,
459
+ s(:call, nil, :bar))))
460
+ end
461
+
462
+ it 'works with next with a function call without parentheses' do
463
+ 'foo do; next foo bar; end'.
464
+ must_be_parsed_as s(:iter,
465
+ s(:call, nil, :foo),
466
+ 0,
467
+ s(:next,
468
+ s(:call, nil, :foo,
469
+ s(:call, nil, :bar))))
470
+ end
471
+
472
+ it 'works with break with no arguments' do
473
+ 'foo do; break; end'.
459
474
  must_be_parsed_as s(:iter,
460
475
  s(:call, nil, :foo),
461
476
  0,
462
477
  s(:break))
463
478
  end
464
479
 
465
- it "works with break with one argument" do
466
- "foo do; break bar; end".
480
+ it 'works with break with one argument' do
481
+ 'foo do; break bar; end'.
467
482
  must_be_parsed_as s(:iter,
468
483
  s(:call, nil, :foo),
469
484
  0,
470
485
  s(:break, s(:call, nil, :bar)))
471
486
  end
472
487
 
473
- it "works with break with several arguments" do
474
- "foo do; break bar, baz; end".
488
+ it 'works with break with several arguments' do
489
+ 'foo do; break bar, baz; end'.
475
490
  must_be_parsed_as s(:iter,
476
491
  s(:call, nil, :foo),
477
492
  0,
@@ -481,199 +496,233 @@ describe RipperRubyParser::Parser do
481
496
  s(:call, nil, :baz))))
482
497
  end
483
498
 
484
- it "works with redo" do
485
- "foo do; redo; end".
499
+ it 'works with break with a function call with parentheses' do
500
+ 'foo do; break foo(bar); end'.
501
+ must_be_parsed_as s(:iter,
502
+ s(:call, nil, :foo),
503
+ 0,
504
+ s(:break,
505
+ s(:call, nil, :foo,
506
+ s(:call, nil, :bar))))
507
+ end
508
+
509
+ it 'works with break with a function call without parentheses' do
510
+ 'foo do; break foo bar; end'.
511
+ must_be_parsed_as s(:iter,
512
+ s(:call, nil, :foo),
513
+ 0,
514
+ s(:break,
515
+ s(:call, nil, :foo,
516
+ s(:call, nil, :bar))))
517
+ end
518
+
519
+ it 'works with redo' do
520
+ 'foo do; redo; end'.
486
521
  must_be_parsed_as s(:iter,
487
522
  s(:call, nil, :foo),
488
523
  0,
489
524
  s(:redo))
490
525
  end
491
526
 
492
- it "works with zero arguments" do
493
- "foo do ||; end".
527
+ it 'works with zero arguments' do
528
+ 'foo do ||; end'.
494
529
  must_be_parsed_as s(:iter,
495
530
  s(:call, nil, :foo),
496
531
  s(:args))
497
532
  end
498
533
 
499
- it "works with one argument" do
500
- "foo do |bar|; end".
534
+ it 'works with one argument' do
535
+ 'foo do |bar|; end'.
501
536
  must_be_parsed_as s(:iter,
502
537
  s(:call, nil, :foo),
503
538
  s(:args, :bar))
504
539
  end
505
540
 
506
- it "works with multiple arguments" do
507
- "foo do |bar, baz|; end".
541
+ it 'works with multiple arguments' do
542
+ 'foo do |bar, baz|; end'.
508
543
  must_be_parsed_as s(:iter,
509
544
  s(:call, nil, :foo),
510
545
  s(:args, :bar, :baz))
511
546
  end
512
547
 
513
- it "works with a single splat argument" do
514
- "foo do |*bar|; end".
548
+ it 'works with a single splat argument' do
549
+ 'foo do |*bar|; end'.
515
550
  must_be_parsed_as s(:iter,
516
551
  s(:call, nil, :foo),
517
552
  s(:args, :"*bar"))
518
553
  end
519
554
 
520
- it "works with a combination of regular arguments and a splat argument" do
521
- "foo do |bar, *baz|; end".
555
+ it 'works with a combination of regular arguments and a splat argument' do
556
+ 'foo do |bar, *baz|; end'.
522
557
  must_be_parsed_as s(:iter,
523
558
  s(:call, nil, :foo),
524
559
  s(:args, :bar, :"*baz"))
525
560
  end
526
561
  end
527
562
 
528
- describe "for yield" do
529
- it "works with no arguments and no brackets" do
530
- "yield".
563
+ describe 'for yield' do
564
+ it 'works with no arguments and no brackets' do
565
+ 'yield'.
531
566
  must_be_parsed_as s(:yield)
532
567
  end
533
568
 
534
- it "works with brackets but no arguments" do
535
- "yield()".
569
+ it 'works with brackets but no arguments' do
570
+ 'yield()'.
536
571
  must_be_parsed_as s(:yield)
537
572
  end
538
573
 
539
- it "works with one argument and no brackets" do
540
- "yield foo".
574
+ it 'works with one argument and no brackets' do
575
+ 'yield foo'.
541
576
  must_be_parsed_as s(:yield, s(:call, nil, :foo))
542
577
  end
543
578
 
544
- it "works with one argument and brackets" do
545
- "yield(foo)".
579
+ it 'works with one argument and brackets' do
580
+ 'yield(foo)'.
546
581
  must_be_parsed_as s(:yield, s(:call, nil, :foo))
547
582
  end
548
583
 
549
- it "works with multiple arguments and no brackets" do
550
- "yield foo, bar".
584
+ it 'works with multiple arguments and no brackets' do
585
+ 'yield foo, bar'.
551
586
  must_be_parsed_as s(:yield,
552
587
  s(:call, nil, :foo),
553
588
  s(:call, nil, :bar))
554
589
  end
555
590
 
556
- it "works with multiple arguments and brackets" do
557
- "yield(foo, bar)".
591
+ it 'works with multiple arguments and brackets' do
592
+ 'yield(foo, bar)'.
558
593
  must_be_parsed_as s(:yield,
559
594
  s(:call, nil, :foo),
560
595
  s(:call, nil, :bar))
561
596
  end
562
597
 
563
- it "works with splat" do
564
- "yield foo, *bar".
598
+ it 'works with splat' do
599
+ 'yield foo, *bar'.
565
600
  must_be_parsed_as s(:yield,
566
601
  s(:call, nil, :foo),
567
602
  s(:splat, s(:call, nil, :bar)))
568
603
  end
604
+
605
+ it 'works with a function call with parentheses' do
606
+ 'yield foo(bar)'.
607
+ must_be_parsed_as s(:yield,
608
+ s(:call, nil, :foo,
609
+ s(:call, nil, :bar)))
610
+ end
611
+
612
+ it 'works with a function call without parentheses' do
613
+ 'yield foo bar'.
614
+ must_be_parsed_as s(:yield,
615
+ s(:call, nil, :foo,
616
+ s(:call, nil, :bar)))
617
+ end
569
618
  end
570
619
 
571
- describe "for the __FILE__ keyword" do
572
- describe "when not passing a file name" do
620
+ describe 'for the __FILE__ keyword' do
621
+ describe 'when not passing a file name' do
573
622
  it "creates a string sexp with value '(string)'" do
574
- "__FILE__".
575
- must_be_parsed_as s(:str, "(string)")
623
+ '__FILE__'.
624
+ must_be_parsed_as s(:str, '(string)')
576
625
  end
577
626
  end
578
627
 
579
- describe "when passing a file name" do
580
- it "creates a string sexp with the file name" do
581
- result = parser.parse "__FILE__", "foo"
582
- result.must_equal s(:str, "foo")
628
+ describe 'when passing a file name' do
629
+ it 'creates a string sexp with the file name' do
630
+ result = parser.parse '__FILE__', 'foo'
631
+ result.must_equal s(:str, 'foo')
583
632
  end
584
633
  end
585
634
  end
586
635
 
587
- describe "for the __LINE__ keyword" do
588
- it "creates a literal sexp with value of the line number" do
589
- "__LINE__".
636
+ describe 'for the __LINE__ keyword' do
637
+ it 'creates a literal sexp with value of the line number' do
638
+ '__LINE__'.
590
639
  must_be_parsed_as s(:lit, 1)
591
640
  "\n__LINE__".
592
641
  must_be_parsed_as s(:lit, 2)
593
642
  end
594
643
  end
595
644
 
596
- describe "for the END keyword" do
597
- it "converts to a :postexe iterator" do
598
- "END { foo }".
645
+ describe 'for the END keyword' do
646
+ it 'converts to a :postexe iterator' do
647
+ 'END { foo }'.
599
648
  must_be_parsed_as s(:iter, s(:postexe), 0, s(:call, nil, :foo))
600
649
  end
601
650
  end
602
651
 
603
- describe "for the BEGIN keyword" do
604
- it "converts to a :preexe iterator" do
605
- "BEGIN { foo }".
652
+ describe 'for the BEGIN keyword' do
653
+ it 'converts to a :preexe iterator' do
654
+ 'BEGIN { foo }'.
606
655
  must_be_parsed_as s(:iter, s(:preexe), s(:args), s(:call, nil, :foo))
607
656
  end
608
657
  end
609
658
 
610
- describe "for constant lookups" do
611
- it "works when explicitely starting from the root namespace" do
612
- "::Foo".
659
+ describe 'for constant lookups' do
660
+ it 'works when explicitely starting from the root namespace' do
661
+ '::Foo'.
613
662
  must_be_parsed_as s(:colon3, :Foo)
614
663
  end
615
664
 
616
- it "works with a three-level constant lookup" do
617
- "Foo::Bar::Baz".
665
+ it 'works with a three-level constant lookup' do
666
+ 'Foo::Bar::Baz'.
618
667
  must_be_parsed_as s(:colon2,
619
668
  s(:colon2, s(:const, :Foo), :Bar),
620
669
  :Baz)
621
670
  end
622
671
 
623
- it "works looking up a constant in a non-constant" do
624
- "foo::Bar".must_be_parsed_as s(:colon2,
672
+ it 'works looking up a constant in a non-constant' do
673
+ 'foo::Bar'.must_be_parsed_as s(:colon2,
625
674
  s(:call, nil, :foo),
626
675
  :Bar)
627
676
  end
628
677
  end
629
678
 
630
- describe "for variable references" do
631
- it "works for self" do
632
- "self".
679
+ describe 'for variable references' do
680
+ it 'works for self' do
681
+ 'self'.
633
682
  must_be_parsed_as s(:self)
634
683
  end
635
684
 
636
- it "works for instance variables" do
637
- "@foo".
685
+ it 'works for instance variables' do
686
+ '@foo'.
638
687
  must_be_parsed_as s(:ivar, :@foo)
639
688
  end
640
689
 
641
- it "works for global variables" do
642
- "$foo".
690
+ it 'works for global variables' do
691
+ '$foo'.
643
692
  must_be_parsed_as s(:gvar, :$foo)
644
693
  end
645
694
 
646
- it "works for regexp match references" do
647
- "$1".
695
+ it 'works for regexp match references' do
696
+ '$1'.
648
697
  must_be_parsed_as s(:nth_ref, 1)
649
698
  end
650
699
 
651
700
  specify { "$'".must_be_parsed_as s(:back_ref, :"'") }
652
- specify { "$&".must_be_parsed_as s(:back_ref, :"&") }
701
+ specify { '$&'.must_be_parsed_as s(:back_ref, :"&") }
653
702
 
654
- it "works for class variables" do
655
- "@@foo".
703
+ it 'works for class variables' do
704
+ '@@foo'.
656
705
  must_be_parsed_as s(:cvar, :@@foo)
657
706
  end
658
707
  end
659
708
 
660
- describe "for single assignment" do
661
- it "works when assigning to an instance variable" do
662
- "@foo = bar".
709
+ describe 'for single assignment' do
710
+ it 'works when assigning to an instance variable' do
711
+ '@foo = bar'.
663
712
  must_be_parsed_as s(:iasgn,
664
713
  :@foo,
665
714
  s(:call, nil, :bar))
666
715
  end
667
716
 
668
- it "works when assigning to a constant" do
669
- "FOO = bar".
717
+ it 'works when assigning to a constant' do
718
+ 'FOO = bar'.
670
719
  must_be_parsed_as s(:cdecl,
671
720
  :FOO,
672
721
  s(:call, nil, :bar))
673
722
  end
674
723
 
675
- it "works when assigning to a collection element" do
676
- "foo[bar] = baz".
724
+ it 'works when assigning to a collection element' do
725
+ 'foo[bar] = baz'.
677
726
  must_be_parsed_as s(:attrasgn,
678
727
  s(:call, nil, :foo),
679
728
  :[]=,
@@ -681,47 +730,47 @@ describe RipperRubyParser::Parser do
681
730
  s(:call, nil, :baz))
682
731
  end
683
732
 
684
- it "works when assigning to an attribute" do
685
- "foo.bar = baz".
733
+ it 'works when assigning to an attribute' do
734
+ 'foo.bar = baz'.
686
735
  must_be_parsed_as s(:attrasgn,
687
736
  s(:call, nil, :foo),
688
737
  :bar=,
689
738
  s(:call, nil, :baz))
690
739
  end
691
740
 
692
- it "works when assigning to a class variable" do
693
- "@@foo = bar".
741
+ it 'works when assigning to a class variable' do
742
+ '@@foo = bar'.
694
743
  must_be_parsed_as s(:cvdecl,
695
744
  :@@foo,
696
745
  s(:call, nil, :bar))
697
746
  end
698
747
 
699
- it "works when assigning to a class variable inside a method" do
700
- "def foo; @@bar = baz; end".
748
+ it 'works when assigning to a class variable inside a method' do
749
+ 'def foo; @@bar = baz; end'.
701
750
  must_be_parsed_as s(:defn,
702
751
  :foo, s(:args),
703
752
  s(:cvasgn, :@@bar, s(:call, nil, :baz)))
704
753
  end
705
754
 
706
- it "works when assigning to a class variable inside a method with a receiver" do
707
- "def self.foo; @@bar = baz; end".
755
+ it 'works when assigning to a class variable inside a method with a receiver' do
756
+ 'def self.foo; @@bar = baz; end'.
708
757
  must_be_parsed_as s(:defs,
709
758
  s(:self),
710
759
  :foo, s(:args),
711
760
  s(:cvasgn, :@@bar, s(:call, nil, :baz)))
712
761
  end
713
762
 
714
- it "works when assigning to a global variable" do
715
- "$foo = bar".
763
+ it 'works when assigning to a global variable' do
764
+ '$foo = bar'.
716
765
  must_be_parsed_as s(:gasgn,
717
766
  :$foo,
718
767
  s(:call, nil, :bar))
719
768
  end
720
769
  end
721
770
 
722
- describe "for operator assignment" do
723
- it "works with +=" do
724
- "foo += bar".
771
+ describe 'for operator assignment' do
772
+ it 'works with +=' do
773
+ 'foo += bar'.
725
774
  must_be_parsed_as s(:lasgn,
726
775
  :foo,
727
776
  s(:call,
@@ -730,8 +779,8 @@ describe RipperRubyParser::Parser do
730
779
  s(:call, nil, :bar)))
731
780
  end
732
781
 
733
- it "works with -=" do
734
- "foo -= bar".
782
+ it 'works with -=' do
783
+ 'foo -= bar'.
735
784
  must_be_parsed_as s(:lasgn,
736
785
  :foo,
737
786
  s(:call,
@@ -740,16 +789,16 @@ describe RipperRubyParser::Parser do
740
789
  s(:call, nil, :bar)))
741
790
  end
742
791
 
743
- it "works with ||=" do
744
- "foo ||= bar".
792
+ it 'works with ||=' do
793
+ 'foo ||= bar'.
745
794
  must_be_parsed_as s(:op_asgn_or,
746
795
  s(:lvar, :foo),
747
796
  s(:lasgn, :foo,
748
797
  s(:call, nil, :bar)))
749
798
  end
750
799
 
751
- it "works when assigning to an instance variable" do
752
- "@foo += bar".
800
+ it 'works when assigning to an instance variable' do
801
+ '@foo += bar'.
753
802
  must_be_parsed_as s(:iasgn,
754
803
  :@foo,
755
804
  s(:call,
@@ -758,8 +807,8 @@ describe RipperRubyParser::Parser do
758
807
  s(:call, nil, :bar)))
759
808
  end
760
809
 
761
- it "works when assigning to a collection element" do
762
- "foo[bar] += baz".
810
+ it 'works when assigning to a collection element' do
811
+ 'foo[bar] += baz'.
763
812
  must_be_parsed_as s(:op_asgn1,
764
813
  s(:call, nil, :foo),
765
814
  s(:arglist, s(:call, nil, :bar)),
@@ -767,8 +816,8 @@ describe RipperRubyParser::Parser do
767
816
  s(:call, nil, :baz))
768
817
  end
769
818
 
770
- it "works with ||= when assigning to a collection element" do
771
- "foo[bar] ||= baz".
819
+ it 'works with ||= when assigning to a collection element' do
820
+ 'foo[bar] ||= baz'.
772
821
  must_be_parsed_as s(:op_asgn1,
773
822
  s(:call, nil, :foo),
774
823
  s(:arglist, s(:call, nil, :bar)),
@@ -776,8 +825,8 @@ describe RipperRubyParser::Parser do
776
825
  s(:call, nil, :baz))
777
826
  end
778
827
 
779
- it "works when assigning to an attribute" do
780
- "foo.bar += baz".
828
+ it 'works when assigning to an attribute' do
829
+ 'foo.bar += baz'.
781
830
  must_be_parsed_as s(:op_asgn2,
782
831
  s(:call, nil, :foo),
783
832
  :bar=,
@@ -785,8 +834,8 @@ describe RipperRubyParser::Parser do
785
834
  s(:call, nil, :baz))
786
835
  end
787
836
 
788
- it "works with ||= when assigning to an attribute" do
789
- "foo.bar ||= baz".
837
+ it 'works with ||= when assigning to an attribute' do
838
+ 'foo.bar ||= baz'.
790
839
  must_be_parsed_as s(:op_asgn2,
791
840
  s(:call, nil, :foo),
792
841
  :bar=,
@@ -795,9 +844,9 @@ describe RipperRubyParser::Parser do
795
844
  end
796
845
  end
797
846
 
798
- describe "for multiple assignment" do
799
- it "works the same number of items on each side" do
800
- "foo, bar = baz, qux".
847
+ describe 'for multiple assignment' do
848
+ it 'works the same number of items on each side' do
849
+ 'foo, bar = baz, qux'.
801
850
  must_be_parsed_as s(:masgn,
802
851
  s(:array, s(:lasgn, :foo), s(:lasgn, :bar)),
803
852
  s(:array,
@@ -805,16 +854,16 @@ describe RipperRubyParser::Parser do
805
854
  s(:call, nil, :qux)))
806
855
  end
807
856
 
808
- it "works with a single item on the right-hand side" do
809
- "foo, bar = baz".
857
+ it 'works with a single item on the right-hand side' do
858
+ 'foo, bar = baz'.
810
859
  must_be_parsed_as s(:masgn,
811
860
  s(:array, s(:lasgn, :foo), s(:lasgn, :bar)),
812
861
  s(:to_ary,
813
862
  s(:call, nil, :baz)))
814
863
  end
815
864
 
816
- it "works with left-hand splat" do
817
- "foo, *bar = baz, qux".
865
+ it 'works with left-hand splat' do
866
+ 'foo, *bar = baz, qux'.
818
867
  must_be_parsed_as s(:masgn,
819
868
  s(:array, s(:lasgn, :foo), s(:splat, s(:lasgn, :bar))),
820
869
  s(:array,
@@ -822,15 +871,15 @@ describe RipperRubyParser::Parser do
822
871
  s(:call, nil, :qux)))
823
872
  end
824
873
 
825
- it "works with brackets around the left-hand side" do
826
- "(foo, bar) = baz".
874
+ it 'works with brackets around the left-hand side' do
875
+ '(foo, bar) = baz'.
827
876
  must_be_parsed_as s(:masgn,
828
877
  s(:array, s(:lasgn, :foo), s(:lasgn, :bar)),
829
878
  s(:to_ary, s(:call, nil, :baz)))
830
879
  end
831
880
 
832
- it "works with complex destructuring" do
833
- "foo, (bar, baz) = qux".
881
+ it 'works with complex destructuring' do
882
+ 'foo, (bar, baz) = qux'.
834
883
  must_be_parsed_as s(:masgn,
835
884
  s(:array,
836
885
  s(:lasgn, :foo),
@@ -839,8 +888,8 @@ describe RipperRubyParser::Parser do
839
888
  s(:to_ary, s(:call, nil, :qux)))
840
889
  end
841
890
 
842
- it "works with complex destructuring of the value" do
843
- "foo, (bar, baz) = [qux, [quz, quuz]]".
891
+ it 'works with complex destructuring of the value' do
892
+ 'foo, (bar, baz) = [qux, [quz, quuz]]'.
844
893
  must_be_parsed_as s(:masgn,
845
894
  s(:array,
846
895
  s(:lasgn, :foo),
@@ -851,22 +900,22 @@ describe RipperRubyParser::Parser do
851
900
  s(:array, s(:call, nil, :quz), s(:call, nil, :quuz)))))
852
901
  end
853
902
 
854
- it "works with instance variables" do
855
- "@foo, @bar = baz".
903
+ it 'works with instance variables' do
904
+ '@foo, @bar = baz'.
856
905
  must_be_parsed_as s(:masgn,
857
906
  s(:array, s(:iasgn, :@foo), s(:iasgn, :@bar)),
858
907
  s(:to_ary, s(:call, nil, :baz)))
859
908
  end
860
909
 
861
- it "works with class variables" do
862
- "@@foo, @@bar = baz".
910
+ it 'works with class variables' do
911
+ '@@foo, @@bar = baz'.
863
912
  must_be_parsed_as s(:masgn,
864
913
  s(:array, s(:cvdecl, :@@foo), s(:cvdecl, :@@bar)),
865
914
  s(:to_ary, s(:call, nil, :baz)))
866
915
  end
867
916
 
868
- it "works with attributes" do
869
- "foo.bar, foo.baz = qux".
917
+ it 'works with attributes' do
918
+ 'foo.bar, foo.baz = qux'.
870
919
  must_be_parsed_as s(:masgn,
871
920
  s(:array,
872
921
  s(:attrasgn, s(:call, nil, :foo), :bar=),
@@ -874,8 +923,8 @@ describe RipperRubyParser::Parser do
874
923
  s(:to_ary, s(:call, nil, :qux)))
875
924
  end
876
925
 
877
- it "works with collection elements" do
878
- "foo[1], bar[2] = baz".
926
+ it 'works with collection elements' do
927
+ 'foo[1], bar[2] = baz'.
879
928
  must_be_parsed_as s(:masgn,
880
929
  s(:array,
881
930
  s(:attrasgn,
@@ -885,15 +934,15 @@ describe RipperRubyParser::Parser do
885
934
  s(:to_ary, s(:call, nil, :baz)))
886
935
  end
887
936
 
888
- it "works with constants" do
889
- "Foo, Bar = baz".
937
+ it 'works with constants' do
938
+ 'Foo, Bar = baz'.
890
939
  must_be_parsed_as s(:masgn,
891
940
  s(:array, s(:cdecl, :Foo), s(:cdecl, :Bar)),
892
941
  s(:to_ary, s(:call, nil, :baz)))
893
942
  end
894
943
 
895
- it "works with instance variables and splat" do
896
- "@foo, *@bar = baz".
944
+ it 'works with instance variables and splat' do
945
+ '@foo, *@bar = baz'.
897
946
  must_be_parsed_as s(:masgn,
898
947
  s(:array,
899
948
  s(:iasgn, :@foo),
@@ -903,126 +952,102 @@ describe RipperRubyParser::Parser do
903
952
  end
904
953
  end
905
954
 
906
- describe "for operators" do
907
- it "handles :!=" do
908
- "foo != bar".
955
+ describe 'for operators' do
956
+ it 'handles :!=' do
957
+ 'foo != bar'.
909
958
  must_be_parsed_as s(:call,
910
959
  s(:call, nil, :foo),
911
960
  :!=,
912
961
  s(:call, nil, :bar))
913
962
  end
914
963
 
915
- it "handles :=~ with two non-literals" do
916
- "foo =~ bar".
964
+ it 'handles :=~ with two non-literals' do
965
+ 'foo =~ bar'.
917
966
  must_be_parsed_as s(:call,
918
967
  s(:call, nil, :foo),
919
968
  :=~,
920
969
  s(:call, nil, :bar))
921
970
  end
922
971
 
923
- it "handles :=~ with literal regexp on the left hand side" do
924
- "/foo/ =~ bar".
972
+ it 'handles :=~ with literal regexp on the left hand side' do
973
+ '/foo/ =~ bar'.
925
974
  must_be_parsed_as s(:match2,
926
975
  s(:lit, /foo/),
927
976
  s(:call, nil, :bar))
928
977
  end
929
978
 
930
- it "handles :=~ with literal regexp on the right hand side" do
931
- "foo =~ /bar/".
979
+ it 'handles :=~ with literal regexp on the right hand side' do
980
+ 'foo =~ /bar/'.
932
981
  must_be_parsed_as s(:match3,
933
982
  s(:lit, /bar/),
934
983
  s(:call, nil, :foo))
935
984
  end
936
985
 
937
- it "handles unary minus with a number literal" do
938
- "-1".
939
- must_be_parsed_as s(:lit, -1)
940
- end
941
-
942
- it "handles unary minus with a non-literal" do
943
- "-foo".
944
- must_be_parsed_as s(:call,
945
- s(:call, nil, :foo),
946
- :-@)
947
- end
948
-
949
- it "handles unary plus with a number literal" do
950
- "+ 1".
951
- must_be_parsed_as s(:lit, 1)
952
- end
953
-
954
- it "handles unary plus with a non-literal" do
955
- "+ foo".
956
- must_be_parsed_as s(:call,
957
- s(:call, nil, :foo),
958
- :+@)
959
- end
960
-
961
- it "handles unary !" do
962
- "!foo".
986
+ it 'handles unary !' do
987
+ '!foo'.
963
988
  must_be_parsed_as s(:call, s(:call, nil, :foo), :!)
964
989
  end
965
990
 
966
- it "converts :not to :!" do
967
- "not foo".
991
+ it 'converts :not to :!' do
992
+ 'not foo'.
968
993
  must_be_parsed_as s(:call, s(:call, nil, :foo), :!)
969
994
  end
970
995
 
971
- it "handles unary ! with a number literal" do
972
- "!1".
996
+ it 'handles unary ! with a number literal' do
997
+ '!1'.
973
998
  must_be_parsed_as s(:call, s(:lit, 1), :!)
974
999
  end
975
1000
 
976
- it "handles the range operator with positive number literals" do
977
- "1..2".
1001
+ it 'handles the range operator with positive number literals' do
1002
+ '1..2'.
978
1003
  must_be_parsed_as s(:lit, 1..2)
979
1004
  end
980
1005
 
981
- it "handles the range operator with negative number literals" do
982
- "-1..-2".
1006
+ it 'handles the range operator with negative number literals' do
1007
+ '-1..-2'.
983
1008
  must_be_parsed_as s(:lit, -1..-2)
984
1009
  end
985
1010
 
986
- it "handles the range operator with string literals" do
1011
+ it 'handles the range operator with string literals' do
987
1012
  "'a'..'z'".
988
1013
  must_be_parsed_as s(:dot2,
989
- s(:str, "a"),
990
- s(:str, "z"))
1014
+ s(:str, 'a'),
1015
+ s(:str, 'z'))
991
1016
  end
992
1017
 
993
- it "handles the range operator with non-literals" do
994
- "foo..bar".
1018
+ it 'handles the range operator with non-literals' do
1019
+ 'foo..bar'.
995
1020
  must_be_parsed_as s(:dot2,
996
1021
  s(:call, nil, :foo),
997
1022
  s(:call, nil, :bar))
998
1023
  end
999
1024
 
1000
- it "handles the exclusive range operator with positive number literals" do
1001
- "1...2".
1025
+ it 'handles the exclusive range operator with positive number literals' do
1026
+ '1...2'.
1002
1027
  must_be_parsed_as s(:lit, 1...2)
1003
1028
  end
1004
1029
 
1005
- it "handles the exclusive range operator with negative number literals" do
1006
- "-1...-2".
1030
+ it 'handles the exclusive range operator with negative number literals' do
1031
+ '-1...-2'.
1007
1032
  must_be_parsed_as s(:lit, -1...-2)
1008
1033
  end
1009
1034
 
1010
- it "handles the exclusive range operator with string literals" do
1035
+ it 'handles the exclusive range operator with string literals' do
1011
1036
  "'a'...'z'".
1012
1037
  must_be_parsed_as s(:dot3,
1013
- s(:str, "a"),
1014
- s(:str, "z"))
1038
+ s(:str, 'a'),
1039
+ s(:str, 'z'))
1015
1040
  end
1016
1041
 
1017
- it "handles the exclusive range operator with non-literals" do
1018
- "foo...bar".
1042
+ it 'handles the exclusive range operator with non-literals' do
1043
+ 'foo...bar'.
1019
1044
  must_be_parsed_as s(:dot3,
1020
1045
  s(:call, nil, :foo),
1021
1046
  s(:call, nil, :bar))
1022
1047
  end
1023
1048
 
1024
- it "handles the ternary operator" do
1025
- "foo ? bar : baz".
1049
+ it 'handles the ternary operator' do
1050
+ 'foo ? bar : baz'.
1026
1051
  must_be_parsed_as s(:if,
1027
1052
  s(:call, nil, :foo),
1028
1053
  s(:call, nil, :bar),
@@ -1030,9 +1055,9 @@ describe RipperRubyParser::Parser do
1030
1055
  end
1031
1056
  end
1032
1057
 
1033
- describe "for expressions" do
1034
- it "handles assignment inside binary operator expressions" do
1035
- "foo + (bar = baz)".
1058
+ describe 'for expressions' do
1059
+ it 'handles assignment inside binary operator expressions' do
1060
+ 'foo + (bar = baz)'.
1036
1061
  must_be_parsed_as s(:call,
1037
1062
  s(:call, nil, :foo),
1038
1063
  :+,
@@ -1041,8 +1066,8 @@ describe RipperRubyParser::Parser do
1041
1066
  s(:call, nil, :baz)))
1042
1067
  end
1043
1068
 
1044
- it "handles assignment inside unary operator expressions" do
1045
- "+(foo = bar)".
1069
+ it 'handles assignment inside unary operator expressions' do
1070
+ '+(foo = bar)'.
1046
1071
  must_be_parsed_as s(:call,
1047
1072
  s(:lasgn, :foo, s(:call, nil, :bar)),
1048
1073
  :+@)
@@ -1051,8 +1076,8 @@ describe RipperRubyParser::Parser do
1051
1076
 
1052
1077
  # Note: differences in the handling of comments are not caught by Sexp's
1053
1078
  # implementation of equality.
1054
- describe "for comments" do
1055
- it "handles method comments" do
1079
+ describe 'for comments' do
1080
+ it 'handles method comments' do
1056
1081
  result = parser.parse "# Foo\ndef foo; end"
1057
1082
  result.must_equal s(:defn,
1058
1083
  :foo,
@@ -1060,7 +1085,7 @@ describe RipperRubyParser::Parser do
1060
1085
  result.comments.must_equal "# Foo\n"
1061
1086
  end
1062
1087
 
1063
- it "handles comments for methods with explicit receiver" do
1088
+ it 'handles comments for methods with explicit receiver' do
1064
1089
  result = parser.parse "# Foo\ndef foo.bar; end"
1065
1090
  result.must_equal s(:defs,
1066
1091
  s(:call, nil, :foo),
@@ -1070,7 +1095,7 @@ describe RipperRubyParser::Parser do
1070
1095
  result.comments.must_equal "# Foo\n"
1071
1096
  end
1072
1097
 
1073
- it "matches comments to the correct entity" do
1098
+ it 'matches comments to the correct entity' do
1074
1099
  result = parser.parse "# Foo\nclass Foo\n# Bar\ndef bar\nend\nend"
1075
1100
  result.must_equal s(:class, :Foo, nil,
1076
1101
  s(:defn, :bar,
@@ -1081,7 +1106,7 @@ describe RipperRubyParser::Parser do
1081
1106
  defn.comments.must_equal "# Bar\n"
1082
1107
  end
1083
1108
 
1084
- it "combines multi-line comments" do
1109
+ it 'combines multi-line comments' do
1085
1110
  result = parser.parse "# Foo\n# Bar\ndef foo; end"
1086
1111
  result.must_equal s(:defn,
1087
1112
  :foo,
@@ -1089,7 +1114,7 @@ describe RipperRubyParser::Parser do
1089
1114
  result.comments.must_equal "# Foo\n# Bar\n"
1090
1115
  end
1091
1116
 
1092
- it "drops comments inside method bodies" do
1117
+ it 'drops comments inside method bodies' do
1093
1118
  result = parser.parse <<-END
1094
1119
  # Foo
1095
1120
  class Foo
@@ -1114,7 +1139,7 @@ describe RipperRubyParser::Parser do
1114
1139
  result[4].comments.must_equal "# bar\n"
1115
1140
  end
1116
1141
 
1117
- it "handles the use of symbols that are keywords" do
1142
+ it 'handles the use of symbols that are keywords' do
1118
1143
  result = parser.parse "# Foo\ndef bar\n:class\nend"
1119
1144
  result.must_equal s(:defn,
1120
1145
  :bar,
@@ -1123,7 +1148,7 @@ describe RipperRubyParser::Parser do
1123
1148
  result.comments.must_equal "# Foo\n"
1124
1149
  end
1125
1150
 
1126
- it "handles use of singleton class inside methods" do
1151
+ it 'handles use of singleton class inside methods' do
1127
1152
  result = parser.parse "# Foo\ndef bar\nclass << self\nbaz\nend\nend"
1128
1153
  result.must_equal s(:defn,
1129
1154
  :bar,
@@ -1136,33 +1161,33 @@ describe RipperRubyParser::Parser do
1136
1161
 
1137
1162
  # Note: differences in the handling of line numbers are not caught by
1138
1163
  # Sexp's implementation of equality.
1139
- describe "assigning line numbers" do
1140
- it "works for a plain method call" do
1141
- result = parser.parse "foo"
1164
+ describe 'assigning line numbers' do
1165
+ it 'works for a plain method call' do
1166
+ result = parser.parse 'foo'
1142
1167
  result.line.must_equal 1
1143
1168
  end
1144
1169
 
1145
- it "works for a method call with brackets" do
1146
- result = parser.parse "foo()"
1170
+ it 'works for a method call with brackets' do
1171
+ result = parser.parse 'foo()'
1147
1172
  result.line.must_equal 1
1148
1173
  end
1149
1174
 
1150
- it "works for a method call with receiver" do
1151
- result = parser.parse "foo.bar"
1175
+ it 'works for a method call with receiver' do
1176
+ result = parser.parse 'foo.bar'
1152
1177
  result.line.must_equal 1
1153
1178
  end
1154
1179
 
1155
- it "works for a method call with receiver and arguments" do
1156
- result = parser.parse "foo.bar baz"
1180
+ it 'works for a method call with receiver and arguments' do
1181
+ result = parser.parse 'foo.bar baz'
1157
1182
  result.line.must_equal 1
1158
1183
  end
1159
1184
 
1160
- it "works for a method call with arguments" do
1161
- result = parser.parse "foo bar"
1185
+ it 'works for a method call with arguments' do
1186
+ result = parser.parse 'foo bar'
1162
1187
  result.line.must_equal 1
1163
1188
  end
1164
1189
 
1165
- it "works for a block with two lines" do
1190
+ it 'works for a block with two lines' do
1166
1191
  result = parser.parse "foo\nbar\n"
1167
1192
  result.sexp_type.must_equal :block
1168
1193
  result[1].line.must_equal 1
@@ -1170,27 +1195,27 @@ describe RipperRubyParser::Parser do
1170
1195
  result.line.must_equal 1
1171
1196
  end
1172
1197
 
1173
- it "works for a constant reference" do
1174
- result = parser.parse "Foo"
1198
+ it 'works for a constant reference' do
1199
+ result = parser.parse 'Foo'
1175
1200
  result.line.must_equal 1
1176
1201
  end
1177
1202
 
1178
- it "works for an instance variable" do
1179
- result = parser.parse "@foo"
1203
+ it 'works for an instance variable' do
1204
+ result = parser.parse '@foo'
1180
1205
  result.line.must_equal 1
1181
1206
  end
1182
1207
 
1183
- it "works for a global variable" do
1184
- result = parser.parse "$foo"
1208
+ it 'works for a global variable' do
1209
+ result = parser.parse '$foo'
1185
1210
  result.line.must_equal 1
1186
1211
  end
1187
1212
 
1188
- it "works for a class variable" do
1189
- result = parser.parse "@@foo"
1213
+ it 'works for a class variable' do
1214
+ result = parser.parse '@@foo'
1190
1215
  result.line.must_equal 1
1191
1216
  end
1192
1217
 
1193
- it "works for a local variable" do
1218
+ it 'works for a local variable' do
1194
1219
  result = parser.parse "foo = bar\nfoo\n"
1195
1220
  result.sexp_type.must_equal :block
1196
1221
  result[1].line.must_equal 1
@@ -1198,67 +1223,67 @@ describe RipperRubyParser::Parser do
1198
1223
  result.line.must_equal 1
1199
1224
  end
1200
1225
 
1201
- it "works for an integer literal" do
1202
- result = parser.parse "42"
1226
+ it 'works for an integer literal' do
1227
+ result = parser.parse '42'
1203
1228
  result.line.must_equal 1
1204
1229
  end
1205
1230
 
1206
- it "works for a float literal" do
1207
- result = parser.parse "3.14"
1231
+ it 'works for a float literal' do
1232
+ result = parser.parse '3.14'
1208
1233
  result.line.must_equal 1
1209
1234
  end
1210
1235
 
1211
- it "works for a regular expression back reference" do
1212
- result = parser.parse "$1"
1236
+ it 'works for a regular expression back reference' do
1237
+ result = parser.parse '$1'
1213
1238
  result.line.must_equal 1
1214
1239
  end
1215
1240
 
1216
- it "works for self" do
1217
- result = parser.parse "self"
1241
+ it 'works for self' do
1242
+ result = parser.parse 'self'
1218
1243
  result.line.must_equal 1
1219
1244
  end
1220
1245
 
1221
- it "works for __FILE__" do
1222
- result = parser.parse "__FILE__"
1246
+ it 'works for __FILE__' do
1247
+ result = parser.parse '__FILE__'
1223
1248
  result.line.must_equal 1
1224
1249
  end
1225
1250
 
1226
- it "works for nil" do
1227
- result = parser.parse "nil"
1251
+ it 'works for nil' do
1252
+ result = parser.parse 'nil'
1228
1253
  result.line.must_equal 1
1229
1254
  end
1230
1255
 
1231
- it "works for a symbol literal" do
1232
- result = parser.parse ":foo"
1256
+ it 'works for a symbol literal' do
1257
+ result = parser.parse ':foo'
1233
1258
  result.line.must_equal 1
1234
1259
  end
1235
1260
 
1236
- it "works for a class definition" do
1237
- result = parser.parse "class Foo; end"
1261
+ it 'works for a class definition' do
1262
+ result = parser.parse 'class Foo; end'
1238
1263
  result.line.must_equal 1
1239
1264
  end
1240
1265
 
1241
- it "works for a module definition" do
1242
- result = parser.parse "module Foo; end"
1266
+ it 'works for a module definition' do
1267
+ result = parser.parse 'module Foo; end'
1243
1268
  result.line.must_equal 1
1244
1269
  end
1245
1270
 
1246
- it "works for a method definition" do
1247
- result = parser.parse "def foo; end"
1271
+ it 'works for a method definition' do
1272
+ result = parser.parse 'def foo; end'
1248
1273
  result.line.must_equal 1
1249
1274
  end
1250
1275
 
1251
- it "works for assignment of the empty hash" do
1252
- result = parser.parse "foo = {}"
1276
+ it 'works for assignment of the empty hash' do
1277
+ result = parser.parse 'foo = {}'
1253
1278
  result.line.must_equal 1
1254
1279
  end
1255
1280
 
1256
- it "works for multiple assignment of empty hashes" do
1257
- result = parser.parse "foo, bar = {}, {}"
1281
+ it 'works for multiple assignment of empty hashes' do
1282
+ result = parser.parse 'foo, bar = {}, {}'
1258
1283
  result.line.must_equal 1
1259
1284
  end
1260
1285
 
1261
- it "assigns line numbers to nested sexps without their own line numbers" do
1286
+ it 'assigns line numbers to nested sexps without their own line numbers' do
1262
1287
  result = parser.parse "foo(bar) do\nnext baz\nend\n"
1263
1288
  result.must_equal s(:iter,
1264
1289
  s(:call, nil, :foo, s(:call, nil, :bar)),
@@ -1270,8 +1295,8 @@ describe RipperRubyParser::Parser do
1270
1295
  nums.must_equal [1, 2]
1271
1296
  end
1272
1297
 
1273
- describe "when a line number is passed" do
1274
- it "shifts all line numbers as appropriate" do
1298
+ describe 'when a line number is passed' do
1299
+ it 'shifts all line numbers as appropriate' do
1275
1300
  result = parser.parse "foo\nbar\n", '(string)', 3
1276
1301
  result.must_equal s(:block,
1277
1302
  s(:call, nil, :foo),