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,435 +1,420 @@
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 instance method definitions' do
8
- it 'treats kwargs as a local variable' do
9
- 'def foo(**bar); bar; end'.
10
- must_be_parsed_as s(:defn,
11
- :foo,
12
- s(:args, :"**bar"),
13
- s(:lvar, :bar))
14
- end
15
-
16
- it 'treats kwargs as a local variable when other arguments are present' do
17
- 'def foo(bar, **baz); baz; end'.
18
- must_be_parsed_as s(:defn,
19
- :foo,
20
- s(:args, :bar, :"**baz"),
21
- s(:lvar, :baz))
22
- end
23
-
24
- it 'treats kwargs as a local variable when an explicit block is present' do
25
- 'def foo(**bar, &baz); bar; end'.
26
- must_be_parsed_as s(:defn,
27
- :foo,
28
- s(:args, :"**bar", :"&baz"),
29
- s(:lvar, :bar))
30
- end
31
-
32
- it 'treats block kwargs as lvars' do
33
- 'def foo(**bar); baz { |**qux| bar; qux }; end'.
34
- must_be_parsed_as s(:defn, :foo,
35
- s(:args, :"**bar"),
36
- s(:iter,
37
- s(:call, nil, :baz),
38
- s(:args, :"**qux"),
39
- s(:block,
40
- s(:lvar, :bar),
41
- s(:lvar, :qux))))
42
- end
43
-
44
- it 'works with a method argument with a default value' do
45
- 'def foo bar=nil; end'.
46
- must_be_parsed_as s(:defn,
47
- :foo,
48
- s(:args, s(:lasgn, :bar, s(:nil))),
49
- s(:nil))
50
- end
51
-
52
- it 'works with several method arguments with default values' do
53
- 'def foo bar=1, baz=2; end'.
54
- must_be_parsed_as s(:defn,
55
- :foo,
56
- s(:args,
57
- s(:lasgn, :bar, s(:lit, 1)),
58
- s(:lasgn, :baz, s(:lit, 2))),
59
- s(:nil))
60
- end
61
-
62
- it 'works with parentheses around the parameter list' do
63
- 'def foo(bar); end'.
64
- must_be_parsed_as s(:defn, :foo, s(:args, :bar), s(:nil))
65
- end
66
-
67
- it 'works with a simple splat' do
68
- 'def foo *bar; end'.
69
- must_be_parsed_as s(:defn, :foo, s(:args, :"*bar"), s(:nil))
70
- end
71
-
72
- it 'works with a regular argument plus splat' do
73
- 'def foo bar, *baz; end'.
74
- must_be_parsed_as s(:defn, :foo, s(:args, :bar, :"*baz"), s(:nil))
75
- end
76
-
77
- it 'works with a nameless splat' do
78
- 'def foo *; end'.
79
- must_be_parsed_as s(:defn,
80
- :foo,
81
- s(:args, :"*"),
82
- s(:nil))
83
- end
84
-
85
- it 'works for a simple case with explicit block parameter' do
86
- 'def foo &bar; end'.
87
- must_be_parsed_as s(:defn,
88
- :foo,
89
- s(:args, :"&bar"),
90
- s(:nil))
91
- end
92
-
93
- it 'works with a regular argument plus explicit block parameter' do
94
- 'def foo bar, &baz; end'.
95
- must_be_parsed_as s(:defn,
96
- :foo,
97
- s(:args, :bar, :"&baz"),
98
- s(:nil))
99
- end
100
-
101
- it 'works with a default value plus explicit block parameter' do
102
- 'def foo bar=1, &baz; end'.
103
- must_be_parsed_as s(:defn,
104
- :foo,
105
- s(:args,
106
- s(:lasgn, :bar, s(:lit, 1)),
107
- :"&baz"),
108
- s(:nil))
6
+ describe "#parse" do
7
+ describe "for instance method definitions" do
8
+ it "treats kwargs as a local variable" do
9
+ _("def foo(**bar); bar; end")
10
+ .must_be_parsed_as s(:defn,
11
+ :foo,
12
+ s(:args, :"**bar"),
13
+ s(:lvar, :bar))
14
+ end
15
+
16
+ it "treats kwargs as a local variable when other arguments are present" do
17
+ _("def foo(bar, **baz); baz; end")
18
+ .must_be_parsed_as s(:defn,
19
+ :foo,
20
+ s(:args, :bar, :"**baz"),
21
+ s(:lvar, :baz))
22
+ end
23
+
24
+ it "treats kwargs as a local variable when an explicit block is present" do
25
+ _("def foo(**bar, &baz); bar; end")
26
+ .must_be_parsed_as s(:defn,
27
+ :foo,
28
+ s(:args, :"**bar", :"&baz"),
29
+ s(:lvar, :bar))
30
+ end
31
+
32
+ it "treats block kwargs as lvars" do
33
+ _("def foo(**bar); baz { |**qux| bar; qux }; end")
34
+ .must_be_parsed_as s(:defn, :foo,
35
+ s(:args, :"**bar"),
36
+ s(:iter,
37
+ s(:call, nil, :baz),
38
+ s(:args, :"**qux"),
39
+ s(:block,
40
+ s(:lvar, :bar),
41
+ s(:lvar, :qux))))
42
+ end
43
+
44
+ it "works with a method argument with a default value" do
45
+ _("def foo bar=nil; end")
46
+ .must_be_parsed_as s(:defn,
47
+ :foo,
48
+ s(:args, s(:lasgn, :bar, s(:nil))),
49
+ s(:nil))
50
+ end
51
+
52
+ it "works with several method arguments with default values" do
53
+ _("def foo bar=1, baz=2; end")
54
+ .must_be_parsed_as s(:defn,
55
+ :foo,
56
+ s(:args,
57
+ s(:lasgn, :bar, s(:lit, 1)),
58
+ s(:lasgn, :baz, s(:lit, 2))),
59
+ s(:nil))
60
+ end
61
+
62
+ it "works with parentheses around the parameter list" do
63
+ _("def foo(bar); end")
64
+ .must_be_parsed_as s(:defn, :foo, s(:args, :bar), s(:nil))
65
+ end
66
+
67
+ it "works with a simple splat" do
68
+ _("def foo *bar; end")
69
+ .must_be_parsed_as s(:defn, :foo, s(:args, :"*bar"), s(:nil))
70
+ end
71
+
72
+ it "works with a regular argument plus splat" do
73
+ _("def foo bar, *baz; end")
74
+ .must_be_parsed_as s(:defn, :foo, s(:args, :bar, :"*baz"), s(:nil))
75
+ end
76
+
77
+ it "works with a nameless splat" do
78
+ _("def foo *; end")
79
+ .must_be_parsed_as s(:defn,
80
+ :foo,
81
+ s(:args, :"*"),
82
+ s(:nil))
83
+ end
84
+
85
+ it "works for a simple case with explicit block parameter" do
86
+ _("def foo &bar; end")
87
+ .must_be_parsed_as s(:defn,
88
+ :foo,
89
+ s(:args, :"&bar"),
90
+ s(:nil))
91
+ end
92
+
93
+ it "works with a regular argument plus explicit block parameter" do
94
+ _("def foo bar, &baz; end")
95
+ .must_be_parsed_as s(:defn,
96
+ :foo,
97
+ s(:args, :bar, :"&baz"),
98
+ s(:nil))
99
+ end
100
+
101
+ it "works with a default value plus explicit block parameter" do
102
+ _("def foo bar=1, &baz; end")
103
+ .must_be_parsed_as s(:defn,
104
+ :foo,
105
+ s(:args,
106
+ s(:lasgn, :bar, s(:lit, 1)),
107
+ :"&baz"),
108
+ s(:nil))
109
109
  end
110
110
 
111
- it 'works with a default value plus mandatory argument' do
112
- 'def foo bar=1, baz; end'.
113
- must_be_parsed_as s(:defn,
114
- :foo,
115
- s(:args,
116
- s(:lasgn, :bar, s(:lit, 1)),
117
- :baz),
118
- s(:nil))
111
+ it "works with a default value plus mandatory argument" do
112
+ _("def foo bar=1, baz; end")
113
+ .must_be_parsed_as s(:defn,
114
+ :foo,
115
+ s(:args,
116
+ s(:lasgn, :bar, s(:lit, 1)),
117
+ :baz),
118
+ s(:nil))
119
119
  end
120
120
 
121
- it 'works with a splat plus explicit block parameter' do
122
- 'def foo *bar, &baz; end'.
123
- must_be_parsed_as s(:defn,
124
- :foo,
125
- s(:args, :"*bar", :"&baz"),
126
- s(:nil))
121
+ it "works with a splat plus explicit block parameter" do
122
+ _("def foo *bar, &baz; end")
123
+ .must_be_parsed_as s(:defn,
124
+ :foo,
125
+ s(:args, :"*bar", :"&baz"),
126
+ s(:nil))
127
127
  end
128
128
 
129
- it 'works with a default value plus splat' do
130
- 'def foo bar=1, *baz; end'.
131
- must_be_parsed_as s(:defn,
132
- :foo,
133
- s(:args,
134
- s(:lasgn, :bar, s(:lit, 1)),
135
- :"*baz"),
136
- s(:nil))
129
+ it "works with a default value plus splat" do
130
+ _("def foo bar=1, *baz; end")
131
+ .must_be_parsed_as s(:defn,
132
+ :foo,
133
+ s(:args,
134
+ s(:lasgn, :bar, s(:lit, 1)),
135
+ :"*baz"),
136
+ s(:nil))
137
137
  end
138
138
 
139
- it 'works with a default value, splat, plus final mandatory arguments' do
140
- 'def foo bar=1, *baz, qux, quuz; end'.
141
- must_be_parsed_as s(:defn,
142
- :foo,
143
- s(:args,
144
- s(:lasgn, :bar, s(:lit, 1)),
145
- :"*baz", :qux, :quuz),
146
- s(:nil))
139
+ it "works with a default value, splat, plus final mandatory arguments" do
140
+ _("def foo bar=1, *baz, qux, quuz; end")
141
+ .must_be_parsed_as s(:defn,
142
+ :foo,
143
+ s(:args,
144
+ s(:lasgn, :bar, s(:lit, 1)),
145
+ :"*baz", :qux, :quuz),
146
+ s(:nil))
147
147
  end
148
148
 
149
- it 'works with a named argument with a default value' do
150
- 'def foo bar: 1; end'.
151
- must_be_parsed_as s(:defn,
152
- :foo,
153
- s(:args,
154
- s(:kwarg, :bar, s(:lit, 1))),
155
- s(:nil))
149
+ it "works with a named argument with a default value" do
150
+ _("def foo bar: 1; end")
151
+ .must_be_parsed_as s(:defn,
152
+ :foo,
153
+ s(:args,
154
+ s(:kwarg, :bar, s(:lit, 1))),
155
+ s(:nil))
156
156
  end
157
157
 
158
- it 'works with a named argument with no default value' do
159
- 'def foo bar:; end'.
160
- must_be_parsed_as s(:defn,
161
- :foo,
162
- s(:args,
163
- s(:kwarg, :bar)),
164
- s(:nil))
158
+ it "works with a named argument with no default value" do
159
+ _("def foo bar:; end")
160
+ .must_be_parsed_as s(:defn,
161
+ :foo,
162
+ s(:args,
163
+ s(:kwarg, :bar)),
164
+ s(:nil))
165
165
  end
166
166
 
167
- it 'works with a double splat' do
168
- 'def foo **bar; end'.
169
- must_be_parsed_as s(:defn,
170
- :foo,
171
- s(:args, :'**bar'),
172
- s(:nil))
167
+ it "works with a double splat" do
168
+ _("def foo **bar; end")
169
+ .must_be_parsed_as s(:defn,
170
+ :foo,
171
+ s(:args, :'**bar'),
172
+ s(:nil))
173
173
  end
174
174
 
175
- it 'works with argument destructuring' do
176
- 'def foo((bar, baz)); end'.
177
- must_be_parsed_as s(:defn, :foo,
178
- s(:args, s(:masgn, :bar, :baz)),
179
- s(:nil))
180
- end
175
+ it "works with argument destructuring" do
176
+ _("def foo((bar, baz)); end")
177
+ .must_be_parsed_as s(:defn, :foo,
178
+ s(:args, s(:masgn, :bar, :baz)),
179
+ s(:nil))
180
+ end
181
181
 
182
- it 'works with argument destructuring including splat' do
183
- 'def foo((bar, *baz)); end'.
184
- must_be_parsed_as s(:defn, :foo,
185
- s(:args, s(:masgn, :bar, :'*baz')),
186
- s(:nil))
187
- end
188
-
189
- it 'works with nested argument destructuring' do
190
- 'def foo((bar, (baz, qux))); end'.
191
- must_be_parsed_as s(:defn, :foo,
192
- s(:args, s(:masgn, :bar, s(:masgn, :baz, :qux))),
193
- s(:nil))
194
- end
195
-
196
- it 'works when the method name is an operator' do
197
- 'def +; end'.
198
- must_be_parsed_as s(:defn, :+, s(:args),
199
- s(:nil))
200
- end
201
-
202
- it 'works when the method name is a keyword' do
203
- 'def for; end'.
204
- must_be_parsed_as s(:defn, :for, s(:args),
205
- s(:nil))
182
+ it "works with argument destructuring including splat" do
183
+ _("def foo((bar, *baz)); end")
184
+ .must_be_parsed_as s(:defn, :foo,
185
+ s(:args, s(:masgn, :bar, :'*baz')),
186
+ s(:nil))
187
+ end
188
+
189
+ it "works with nested argument destructuring" do
190
+ _("def foo((bar, (baz, qux))); end")
191
+ .must_be_parsed_as s(:defn, :foo,
192
+ s(:args, s(:masgn, :bar, s(:masgn, :baz, :qux))),
193
+ s(:nil))
194
+ end
195
+
196
+ it "works when the method name is an operator" do
197
+ _("def +; end")
198
+ .must_be_parsed_as s(:defn, :+, s(:args),
199
+ s(:nil))
200
+ end
201
+
202
+ it "works when the method name is a keyword" do
203
+ _("def for; end")
204
+ .must_be_parsed_as s(:defn, :for, s(:args),
205
+ s(:nil))
206
206
  end
207
207
 
208
- it 'assigns correct line numbers when the body is empty' do
209
- "def bar\nend".
210
- must_be_parsed_as s(:defn,
211
- :bar,
212
- s(:args).line(1),
213
- s(:nil).line(2)).line(1),
214
- with_line_numbers: true
208
+ it "assigns correct line numbers when the body is empty" do
209
+ _("def bar\nend")
210
+ .must_be_parsed_as s(:defn,
211
+ :bar,
212
+ s(:args).line(1),
213
+ s(:nil).line(2)).line(1),
214
+ with_line_numbers: true
215
215
  end
216
216
  end
217
217
 
218
- describe 'for singleton method definitions' do
219
- it 'works with empty body' do
220
- 'def foo.bar; end'.
221
- must_be_parsed_as s(:defs,
222
- s(:call, nil, :foo),
223
- :bar,
224
- s(:args),
225
- s(:nil))
226
- end
227
-
228
- it 'works with a body with multiple statements' do
229
- 'def foo.bar; baz; qux; end'.
230
- must_be_parsed_as s(:defs,
231
- s(:call, nil, :foo),
232
- :bar,
233
- s(:args),
234
- s(:call, nil, :baz),
235
- s(:call, nil, :qux))
236
- end
237
-
238
- it 'works with a simple splat' do
239
- 'def foo.bar *baz; end'.
240
- must_be_parsed_as s(:defs,
241
- s(:call, nil, :foo),
242
- :bar,
243
- s(:args, :"*baz"),
244
- s(:nil))
245
- end
246
-
247
- it 'works when the method name is a keyword' do
248
- 'def foo.for; end'.
249
- must_be_parsed_as s(:defs,
250
- s(:call, nil, :foo),
251
- :for, s(:args),
252
- s(:nil))
218
+ describe "for singleton method definitions" do
219
+ it "works with empty body" do
220
+ _("def foo.bar; end")
221
+ .must_be_parsed_as s(:defs,
222
+ s(:call, nil, :foo),
223
+ :bar,
224
+ s(:args),
225
+ s(:nil))
226
+ end
227
+
228
+ it "works with a body with multiple statements" do
229
+ _("def foo.bar; baz; qux; end")
230
+ .must_be_parsed_as s(:defs,
231
+ s(:call, nil, :foo),
232
+ :bar,
233
+ s(:args),
234
+ s(:call, nil, :baz),
235
+ s(:call, nil, :qux))
236
+ end
237
+
238
+ it "works with a simple splat" do
239
+ _("def foo.bar *baz; end")
240
+ .must_be_parsed_as s(:defs,
241
+ s(:call, nil, :foo),
242
+ :bar,
243
+ s(:args, :"*baz"),
244
+ s(:nil))
245
+ end
246
+
247
+ it "works when the method name is a keyword" do
248
+ _("def foo.for; end")
249
+ .must_be_parsed_as s(:defs,
250
+ s(:call, nil, :foo),
251
+ :for, s(:args),
252
+ s(:nil))
253
253
  end
254
254
  end
255
255
 
256
- describe 'for the alias statement' do
257
- it 'works with regular barewords' do
258
- 'alias foo bar'.
259
- must_be_parsed_as s(:alias,
260
- s(:lit, :foo), s(:lit, :bar))
256
+ describe "for the alias statement" do
257
+ it "works with regular barewords" do
258
+ _("alias foo bar")
259
+ .must_be_parsed_as s(:alias,
260
+ s(:lit, :foo), s(:lit, :bar))
261
261
  end
262
262
 
263
- it 'works with symbols' do
264
- 'alias :foo :bar'.
265
- must_be_parsed_as s(:alias,
266
- s(:lit, :foo), s(:lit, :bar))
263
+ it "works with symbols" do
264
+ _("alias :foo :bar")
265
+ .must_be_parsed_as s(:alias,
266
+ s(:lit, :foo), s(:lit, :bar))
267
267
  end
268
268
 
269
- it 'works with operator barewords' do
270
- 'alias + -'.
271
- must_be_parsed_as s(:alias,
272
- s(:lit, :+), s(:lit, :-))
269
+ it "works with operator barewords" do
270
+ _("alias + -")
271
+ .must_be_parsed_as s(:alias,
272
+ s(:lit, :+), s(:lit, :-))
273
273
  end
274
274
 
275
- it 'treats keywords as symbols' do
276
- 'alias next foo'.
277
- must_be_parsed_as s(:alias, s(:lit, :next), s(:lit, :foo))
275
+ it "treats keywords as symbols" do
276
+ _("alias next foo")
277
+ .must_be_parsed_as s(:alias, s(:lit, :next), s(:lit, :foo))
278
278
  end
279
279
 
280
- it 'works with global variables' do
281
- 'alias $foo $bar'.
282
- must_be_parsed_as s(:valias, :$foo, :$bar)
280
+ it "works with global variables" do
281
+ _("alias $foo $bar")
282
+ .must_be_parsed_as s(:valias, :$foo, :$bar)
283
283
  end
284
284
  end
285
285
 
286
- describe 'for the undef statement' do
287
- it 'works with a single bareword identifier' do
288
- 'undef foo'.
289
- must_be_parsed_as s(:undef, s(:lit, :foo))
286
+ describe "for the undef statement" do
287
+ it "works with a single bareword identifier" do
288
+ _("undef foo")
289
+ .must_be_parsed_as s(:undef, s(:lit, :foo))
290
290
  end
291
291
 
292
- it 'works with a single symbol' do
293
- 'undef :foo'.
294
- must_be_parsed_as s(:undef, s(:lit, :foo))
292
+ it "works with a single symbol" do
293
+ _("undef :foo")
294
+ .must_be_parsed_as s(:undef, s(:lit, :foo))
295
295
  end
296
296
 
297
- it 'works with multiple bareword identifiers' do
298
- 'undef foo, bar'.
299
- must_be_parsed_as s(:block,
300
- s(:undef, s(:lit, :foo)),
301
- s(:undef, s(:lit, :bar)))
297
+ it "works with multiple bareword identifiers" do
298
+ _("undef foo, bar")
299
+ .must_be_parsed_as s(:block,
300
+ s(:undef, s(:lit, :foo)),
301
+ s(:undef, s(:lit, :bar)))
302
302
  end
303
303
 
304
- it 'works with multiple bareword symbols' do
305
- 'undef :foo, :bar'.
306
- must_be_parsed_as s(:block,
307
- s(:undef, s(:lit, :foo)),
308
- s(:undef, s(:lit, :bar)))
304
+ it "works with multiple bareword symbols" do
305
+ _("undef :foo, :bar")
306
+ .must_be_parsed_as s(:block,
307
+ s(:undef, s(:lit, :foo)),
308
+ s(:undef, s(:lit, :bar)))
309
309
  end
310
310
  end
311
311
 
312
- describe 'for the return statement' do
313
- it 'works with no arguments' do
314
- 'return'.
315
- must_be_parsed_as s(:return)
312
+ describe "for the return statement" do
313
+ it "works with no arguments" do
314
+ _("return")
315
+ .must_be_parsed_as s(:return)
316
316
  end
317
317
 
318
- it 'works with one argument' do
319
- 'return foo'.
320
- must_be_parsed_as s(:return,
321
- s(:call, nil, :foo))
318
+ it "works with one argument" do
319
+ _("return foo")
320
+ .must_be_parsed_as s(:return,
321
+ s(:call, nil, :foo))
322
322
  end
323
323
 
324
- it 'works with a splat argument' do
325
- 'return *foo'.
326
- must_be_parsed_as s(:return,
327
- s(:svalue,
328
- s(:splat,
329
- s(:call, nil, :foo))))
324
+ it "works with a splat argument" do
325
+ _("return *foo")
326
+ .must_be_parsed_as s(:return,
327
+ s(:svalue,
328
+ s(:splat,
329
+ s(:call, nil, :foo))))
330
330
  end
331
331
 
332
- it 'works with multiple arguments' do
333
- 'return foo, bar'.
334
- must_be_parsed_as s(:return,
335
- s(:array,
336
- s(:call, nil, :foo),
337
- s(:call, nil, :bar)))
332
+ it "works with multiple arguments" do
333
+ _("return foo, bar")
334
+ .must_be_parsed_as s(:return,
335
+ s(:array,
336
+ s(:call, nil, :foo),
337
+ s(:call, nil, :bar)))
338
338
  end
339
339
 
340
- it 'works with a regular argument and a splat argument' do
341
- 'return foo, *bar'.
342
- must_be_parsed_as s(:return,
343
- s(:array,
344
- s(:call, nil, :foo),
345
- s(:splat,
346
- s(:call, nil, :bar))))
340
+ it "works with a regular argument and a splat argument" do
341
+ _("return foo, *bar")
342
+ .must_be_parsed_as s(:return,
343
+ s(:array,
344
+ s(:call, nil, :foo),
345
+ s(:splat,
346
+ s(:call, nil, :bar))))
347
347
  end
348
348
 
349
- it 'works with a function call with parentheses' do
350
- 'return foo(bar)'.
351
- must_be_parsed_as s(:return,
352
- s(:call, nil, :foo,
353
- s(:call, nil, :bar)))
349
+ it "works with a function call with parentheses" do
350
+ _("return foo(bar)")
351
+ .must_be_parsed_as s(:return,
352
+ s(:call, nil, :foo,
353
+ s(:call, nil, :bar)))
354
354
  end
355
355
 
356
- it 'works with a function call without parentheses' do
357
- 'return foo bar'.
358
- must_be_parsed_as s(:return,
359
- s(:call, nil, :foo,
360
- s(:call, nil, :bar)))
356
+ it "works with a function call without parentheses" do
357
+ _("return foo bar")
358
+ .must_be_parsed_as s(:return,
359
+ s(:call, nil, :foo,
360
+ s(:call, nil, :bar)))
361
361
  end
362
362
  end
363
363
 
364
- describe 'for yield' do
365
- it 'works with no arguments and no parentheses' do
366
- 'yield'.
367
- must_be_parsed_as s(:yield)
364
+ describe "for yield" do
365
+ it "works with no arguments and no parentheses" do
366
+ _("yield")
367
+ .must_be_parsed_as s(:yield)
368
368
  end
369
369
 
370
- it 'works with parentheses but no arguments' do
371
- 'yield()'.
372
- must_be_parsed_as s(:yield)
370
+ it "works with parentheses but no arguments" do
371
+ _("yield()")
372
+ .must_be_parsed_as s(:yield)
373
373
  end
374
374
 
375
- it 'works with one argument and no parentheses' do
376
- 'yield foo'.
377
- must_be_parsed_as s(:yield, s(:call, nil, :foo))
375
+ it "works with one argument and no parentheses" do
376
+ _("yield foo")
377
+ .must_be_parsed_as s(:yield, s(:call, nil, :foo))
378
378
  end
379
379
 
380
- it 'works with one argument and parentheses' do
381
- 'yield(foo)'.
382
- must_be_parsed_as s(:yield, s(:call, nil, :foo))
380
+ it "works with one argument and parentheses" do
381
+ _("yield(foo)")
382
+ .must_be_parsed_as s(:yield, s(:call, nil, :foo))
383
383
  end
384
384
 
385
- it 'works with multiple arguments and no parentheses' do
386
- 'yield foo, bar'.
387
- must_be_parsed_as s(:yield,
388
- s(:call, nil, :foo),
389
- s(:call, nil, :bar))
385
+ it "works with multiple arguments and no parentheses" do
386
+ _("yield foo, bar")
387
+ .must_be_parsed_as s(:yield,
388
+ s(:call, nil, :foo),
389
+ s(:call, nil, :bar))
390
390
  end
391
391
 
392
- it 'works with multiple arguments and parentheses' do
393
- 'yield(foo, bar)'.
394
- must_be_parsed_as s(:yield,
395
- s(:call, nil, :foo),
396
- s(:call, nil, :bar))
392
+ it "works with multiple arguments and parentheses" do
393
+ _("yield(foo, bar)")
394
+ .must_be_parsed_as s(:yield,
395
+ s(:call, nil, :foo),
396
+ s(:call, nil, :bar))
397
397
  end
398
398
 
399
- it 'works with splat' do
400
- 'yield foo, *bar'.
401
- must_be_parsed_as s(:yield,
402
- s(:call, nil, :foo),
403
- s(:splat, s(:call, nil, :bar)))
399
+ it "works with splat" do
400
+ _("yield foo, *bar")
401
+ .must_be_parsed_as s(:yield,
402
+ s(:call, nil, :foo),
403
+ s(:splat, s(:call, nil, :bar)))
404
404
  end
405
405
 
406
- it 'works with a function call with parentheses' do
407
- 'yield foo(bar)'.
408
- must_be_parsed_as s(:yield,
409
- s(:call, nil, :foo,
410
- s(:call, nil, :bar)))
406
+ it "works with a function call with parentheses" do
407
+ _("yield foo(bar)")
408
+ .must_be_parsed_as s(:yield,
409
+ s(:call, nil, :foo,
410
+ s(:call, nil, :bar)))
411
411
  end
412
412
 
413
- it 'works with a function call without parentheses' do
414
- 'yield foo bar'.
415
- must_be_parsed_as s(:yield,
416
- s(:call, nil, :foo,
417
- s(:call, nil, :bar)))
418
- end
419
- end
420
-
421
- describe 'when extra compatibility is turned on' do
422
- it 'still treats block kwargs as lvars' do
423
- 'def foo(**bar); baz { |**qux| bar; qux }; end'.
424
- must_be_parsed_as s(:defn, :foo,
425
- s(:args, :"**bar"),
426
- s(:iter,
427
- s(:call, nil, :baz),
428
- s(:args, :"**qux"),
429
- s(:block,
430
- s(:lvar, :bar),
431
- s(:lvar, :qux)))),
432
- extra_compatible: true
413
+ it "works with a function call without parentheses" do
414
+ _("yield foo bar")
415
+ .must_be_parsed_as s(:yield,
416
+ s(:call, nil, :foo,
417
+ s(:call, nil, :bar)))
433
418
  end
434
419
  end
435
420
  end