ParseTree 3.0.8 → 3.0.9

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/.autotest CHANGED
@@ -3,12 +3,18 @@
3
3
  require 'autotest/restart'
4
4
 
5
5
  Autotest.add_hook :initialize do |at|
6
- at.libs << ":../../sexp_processor/dev/lib"
7
- at.extra_files << "test/pt_testcase.rb"
6
+ at.libs << ":../../sexp_processor/3.2.0/lib"
7
+ at.libs << ":../../RubyInline/dev/lib"
8
+ at.libs << ":../../ZenTest/dev/lib"
9
+ at.libs << ":../../minitest/dev/lib"
10
+
11
+ at.extra_files << "../../sexp_processor/dev/3.2.0/pt_testcase.rb"
8
12
 
9
13
  at.extra_class_map["TestRawParseTree"] = "test/test_parse_tree.rb"
10
14
  at.extra_class_map["R2RTestCase"] = "test/test_parse_tree_extensions.rb"
11
15
 
16
+ at.testlib = "minitest/autorun"
17
+
12
18
  at.add_mapping(/pt_testcase/) do |f, _|
13
19
  at.files_matching(/test_.*rb$/)
14
20
  end
@@ -1,3 +1,20 @@
1
+ === 3.0.9 / 2012-05-01
2
+
3
+ * 6 minor enhancements:
4
+
5
+ * Added a bunch of new tests from PTTC.
6
+ * Added masgn handling inside block_pass
7
+ * Added rewrite_iter to unwrap masgns w/ only 1 arg.
8
+ * Handle rewriting block_pass in iter.
9
+ * Imported RawParseTree test data from PTTC.
10
+ * Removed rewrite_masgn requirement for 4 slots.
11
+
12
+ * 3 bug fixes:
13
+
14
+ * Fixed dependencies to ensure they're not going to use ruby_parser 3 and friends.
15
+ * Fixed segv for NODE_BLOCK_PASS in iter (nd_iter == 1... go boom)
16
+ * Remove nil body in iter (I think this is wrong, but whatevs).
17
+
1
18
  === 3.0.8 / 2011-09-27
2
19
 
3
20
  * 1 minor enhancement:
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rubygems'
4
4
  require 'hoe'
5
5
 
6
6
  Hoe.add_include_dirs("../../RubyInline/dev/lib",
7
- "../../sexp_processor/dev/lib",
7
+ "../../sexp_processor/3.2.0/lib",
8
8
  "../../ZenTest/dev/lib",
9
9
  "lib")
10
10
 
@@ -14,12 +14,13 @@ Hoe.spec "ParseTree" do
14
14
  developer 'Ryan Davis', 'ryand-ruby@zenspider.com'
15
15
 
16
16
  clean_globs << File.expand_path("~/.ruby_inline")
17
- extra_deps << ['RubyInline', '>= 3.7.0']
18
- extra_deps << ['sexp_processor', '>= 3.0.0']
17
+
18
+ dependency 'RubyInline', '~> 3.9.0'
19
+ dependency 'sexp_processor', '~> 3.2.0'
19
20
 
20
21
  spec_extras[:require_paths] = proc { |paths| paths << 'test' }
21
22
 
22
- multiruby_skip << "1.9"
23
+ multiruby_skip << "1.9" << "trunk"
23
24
  end
24
25
 
25
26
  task :test => :clean
@@ -43,7 +43,7 @@ end
43
43
 
44
44
  class RawParseTree
45
45
 
46
- VERSION = '3.0.8'
46
+ VERSION = '3.0.9'
47
47
 
48
48
  ##
49
49
  # Front end translation method.
@@ -486,7 +486,9 @@ again:
486
486
 
487
487
  case NODE_BLOCK_PASS:
488
488
  add_to_parse_tree(self, current, node->nd_body, locals);
489
- add_to_parse_tree(self, current, node->nd_iter, locals);
489
+ if (node->nd_iter != (NODE *)1) {
490
+ add_to_parse_tree(self, current, node->nd_iter, locals);
491
+ }
490
492
  break;
491
493
 
492
494
  case NODE_ITER:
@@ -38,7 +38,17 @@ module UnifiedRuby
38
38
  end
39
39
 
40
40
  def rewrite_block_pass exp
41
- if exp.size == 3 then
41
+ case exp.size
42
+ when 2 then
43
+ _, block = exp
44
+ case block.first
45
+ when :lasgn then
46
+ block[-1] = :"&#{block[-1]}"
47
+ exp = block
48
+ else
49
+ raise "huh?: #{block.inspect}"
50
+ end
51
+ when 3 then
42
52
  _, block, recv = exp
43
53
  case recv.first
44
54
  when :super then
@@ -47,6 +57,10 @@ module UnifiedRuby
47
57
  when :call then
48
58
  recv.last << s(:block_pass, block)
49
59
  exp = recv
60
+ when :masgn then
61
+ block[-1] = :"&#{block[-1]}"
62
+ recv.last << block
63
+ exp = recv
50
64
  else
51
65
  raise "huh?: #{recv.inspect}"
52
66
  end
@@ -90,6 +104,21 @@ module UnifiedRuby
90
104
  s(:scope, body)
91
105
  end
92
106
 
107
+ def rewrite_iter(exp)
108
+ t, recv, args, body = exp
109
+
110
+ # unwrap masgn args if there is only 1 thing to assign and it isn't splat
111
+ if Sexp === args and args.sexp_type == :masgn and args.array.size == 2 then
112
+ if args.array.last.sexp_type != :splat then
113
+ args = args.array.last
114
+ end
115
+ end
116
+
117
+ r = s(t, recv, args, body)
118
+ r.delete_at 3 unless body # HACK omg this sucks
119
+ r
120
+ end
121
+
93
122
  def rewrite_call(exp)
94
123
  args = exp.last
95
124
  case args
@@ -234,7 +263,6 @@ module UnifiedRuby
234
263
  alias :rewrite_flip3 :rewrite_flip2
235
264
 
236
265
  def rewrite_masgn(exp)
237
- raise "wtf: #{exp}" unless exp.size == 4 # TODO: remove 2009-01-29
238
266
  t, lhs, lhs_splat, rhs = exp
239
267
 
240
268
  lhs ||= s(:array)
@@ -8,6 +8,7 @@ if test ?d, dir then
8
8
  FileUtils.rm_r dir, :force => true
9
9
  end
10
10
 
11
+ require 'rubygems'
11
12
  require 'minitest/autorun'
12
13
  require 'parse_tree'
13
14
  require 'pt_testcase'
@@ -48,6 +49,2288 @@ class RawParseTree
48
49
  end
49
50
  end
50
51
 
52
+ class ParseTreeTestCase
53
+ @@testcase_order = %w(Ruby RawParseTree ParseTree)
54
+
55
+ add_tests("alias",
56
+ "RawParseTree" => [:class, :X, nil,
57
+ [:scope, [:alias, [:lit, :y], [:lit, :x]]]])
58
+
59
+ add_tests("alias_ugh",
60
+ "RawParseTree" => [:class, :X, nil,
61
+ [:scope, [:alias, [:lit, :y], [:lit, :x]]]])
62
+
63
+ add_tests("and",
64
+ "RawParseTree" => [:and, [:vcall, :a], [:vcall, :b]])
65
+
66
+ add_tests("argscat_inside",
67
+ "RawParseTree" => [:lasgn, :a,
68
+ [:argscat,
69
+ [:array, [:vcall, :b]], [:vcall, :c]]])
70
+
71
+ add_tests("argscat_svalue",
72
+ "RawParseTree" => [:lasgn, :a,
73
+ [:svalue,
74
+ [:argscat,
75
+ [:array, [:vcall, :b], [:vcall, :c]],
76
+ [:vcall, :d]]]])
77
+
78
+ add_tests("argspush",
79
+ "RawParseTree" => [:attrasgn,
80
+ [:vcall, :a],
81
+ :[]=,
82
+ [:argspush,
83
+ [:splat,
84
+ [:vcall, :b]],
85
+ [:vcall, :c]]])
86
+
87
+ add_tests("array",
88
+ "RawParseTree" => [:array, [:lit, 1], [:lit, :b], [:str, "c"]])
89
+
90
+ add_tests("array_pct_W",
91
+ "RawParseTree" => [:array, [:str, "a"], [:str, "b"], [:str, "c"]])
92
+
93
+ add_tests("array_pct_W_dstr",
94
+ "RawParseTree" => [:array,
95
+ [:str, "a"],
96
+ [:dstr, "", [:evstr, [:ivar, :@b]]],
97
+ [:str, "c"]])
98
+
99
+ add_tests("array_pct_w",
100
+ "RawParseTree" => [:array, [:str, "a"], [:str, "b"], [:str, "c"]])
101
+
102
+ add_tests("array_pct_w_dstr",
103
+ "RawParseTree" => [:array,
104
+ [:str, "a"],
105
+ [:str, "#\{@b}"],
106
+ [:str, "c"]]) # TODO: huh?
107
+
108
+ add_tests("attrasgn",
109
+ "RawParseTree" => [:block,
110
+ [:lasgn, :y, [:lit, 0]],
111
+ [:attrasgn, [:lit, 42], :method=,
112
+ [:array, [:lvar, :y]]]])
113
+
114
+ add_tests("attrasgn_index_equals",
115
+ "RawParseTree" => [:attrasgn, [:vcall, :a], :[]=,
116
+ [:array, [:lit, 42], [:lit, 24]]])
117
+
118
+ add_tests("attrasgn_index_equals_space",
119
+ "RawParseTree" => [:block,
120
+ [:lasgn, :a, [:zarray]],
121
+ [:attrasgn, [:lvar, :a], :[]=,
122
+ [:array, [:lit, 42], [:lit, 24]]]])
123
+
124
+ add_tests("attrset",
125
+ "RawParseTree" => [:defn, :writer=, [:attrset, :@writer]])
126
+
127
+ add_tests("back_ref",
128
+ "RawParseTree" => [:array,
129
+ [:back_ref, :&],
130
+ [:back_ref, :"`"],
131
+ [:back_ref, :"'"],
132
+ [:back_ref, :+]])
133
+
134
+ add_tests("begin",
135
+ "RawParseTree" => [:call, [:lit, 1], :+, [:array, [:lit, 1]]])
136
+
137
+ add_tests("begin_def",
138
+ "RawParseTree" => [:defn, :m, [:scope, [:block, [:args], [:nil]]]])
139
+
140
+ add_tests("begin_rescue_ensure",
141
+ "RawParseTree" => [:ensure,
142
+ [:rescue,
143
+ [:vcall, :a],
144
+ [:resbody, nil]],
145
+ [:nil]])
146
+
147
+ add_tests("begin_rescue_ensure_all_empty",
148
+ "RawParseTree" => [:ensure,
149
+ [:rescue,
150
+ [:resbody, nil]],
151
+ [:nil]])
152
+
153
+ add_tests("begin_rescue_twice",
154
+ "RawParseTree" => [:block,
155
+ [:rescue,
156
+ [:vcall, :a],
157
+ [:resbody, nil,
158
+ [:lasgn, :mes, [:gvar, :$!]]]],
159
+ [:rescue,
160
+ [:vcall, :b],
161
+ [:resbody, nil,
162
+ [:lasgn, :mes, [:gvar, :$!]]]]])
163
+
164
+ add_tests("begin_rescue_twice_mri_verbose_flag",
165
+ "RawParseTree" => [:block,
166
+ [:rescue, # no begin
167
+ [:vcall, :a],
168
+ [:resbody, nil,
169
+ [:lasgn, :mes, [:gvar, :$!]]]],
170
+ [:rescue,
171
+ [:vcall, :b],
172
+ [:resbody, nil,
173
+ [:lasgn, :mes, [:gvar, :$!]]]]])
174
+
175
+ add_tests("block_attrasgn",
176
+ "RawParseTree" => [:defs, [:self], :setup,
177
+ [:scope,
178
+ [:block,
179
+ [:args, :ctx],
180
+ [:lasgn, :bind, [:vcall, :allocate]],
181
+ [:attrasgn, [:lvar, :bind], :context=,
182
+ [:array, [:lvar, :ctx]]],
183
+ [:return, [:lvar, :bind]]]]])
184
+
185
+
186
+ add_tests("block_lasgn",
187
+ "RawParseTree" => [:lasgn, :x,
188
+ [:block,
189
+ [:lasgn, :y, [:lit, 1]],
190
+ [:call, [:lvar, :y], :+, [:array, [:lit, 2]]]]])
191
+
192
+ add_tests("block_mystery_block",
193
+ "RawParseTree" => [:iter,
194
+ [:fcall, :a, [:array, [:vcall, :b]]],
195
+ nil,
196
+ [:if,
197
+ [:vcall, :b],
198
+ [:true],
199
+ [:block,
200
+ [:dasgn_curr, :c, [:false]],
201
+ [:iter,
202
+ [:fcall, :d],
203
+ [:dasgn_curr, :x],
204
+ [:dasgn, :c, [:true]]],
205
+ [:dvar, :c]]]])
206
+
207
+ add_tests("block_pass_args_and_splat",
208
+ "RawParseTree" => [:defn, :blah,
209
+ [:scope,
210
+ [:block,
211
+ [:args, :"*args"],
212
+ [:block_arg, :block],
213
+ [:block_pass,
214
+ [:lvar, :block],
215
+ [:fcall, :other,
216
+ [:argscat,
217
+ [:array, [:lit, 42]], [:lvar, :args]]]]]]])
218
+
219
+ add_tests("block_pass_call_0",
220
+ "RawParseTree" => [:block_pass,
221
+ [:vcall, :c], [:call, [:vcall, :a], :b]])
222
+
223
+ add_tests("block_pass_call_1",
224
+ "RawParseTree" => [:block_pass,
225
+ [:vcall, :c],
226
+ [:call, [:vcall, :a], :b, [:array, [:lit, 4]]]])
227
+
228
+ add_tests("block_pass_call_n",
229
+ "RawParseTree" => [:block_pass,
230
+ [:vcall, :c],
231
+ [:call, [:vcall, :a], :b,
232
+ [:array, [:lit, 1], [:lit, 2], [:lit, 3]]]])
233
+
234
+ add_tests("block_pass_fcall_0",
235
+ "RawParseTree" => [:block_pass, [:vcall, :b], [:fcall, :a]])
236
+
237
+ add_tests("block_pass_fcall_1",
238
+ "RawParseTree" => [:block_pass,
239
+ [:vcall, :b],
240
+ [:fcall, :a, [:array, [:lit, 4]]]])
241
+
242
+ add_tests("block_pass_fcall_n",
243
+ "RawParseTree" => [:block_pass,
244
+ [:vcall, :b],
245
+ [:fcall, :a,
246
+ [:array, [:lit, 1], [:lit, 2], [:lit, 3]]]])
247
+
248
+ add_tests("block_pass_omgwtf",
249
+ "RawParseTree" => [:block_pass,
250
+ [:iter,
251
+ [:call, [:const, :Proc], :new],
252
+ [:masgn, nil, [:dasgn_curr, :args], nil],
253
+ [:nil]],
254
+ [:fcall, :define_attr_method,
255
+ [:array, [:lit, :x], [:lit, :sequence_name]]]])
256
+
257
+ add_tests("block_pass_splat",
258
+ "RawParseTree" => [:defn, :blah,
259
+ [:scope,
260
+ [:block,
261
+ [:args, :"*args"],
262
+ [:block_arg, :block],
263
+ [:block_pass,
264
+ [:lvar, :block],
265
+ [:fcall, :other,
266
+ [:splat, [:lvar, :args]]]]]]])
267
+
268
+ add_tests("block_pass_thingy",
269
+ "RawParseTree" => [:block_pass,
270
+ [:vcall, :block],
271
+ [:call, [:vcall, :r], :read_body,
272
+ [:array, [:vcall, :dest]]]])
273
+
274
+ add_tests("lambda_args_star",
275
+ "RawParseTree" => [:iter,
276
+ [:fcall, :lambda],
277
+ [:masgn, nil, [:dasgn_curr, :star], nil],
278
+ [:dvar, :star]])
279
+
280
+ add_tests("lambda_args_anon_star", # FIX: think this is wrong
281
+ "RawParseTree" => [:iter,
282
+ [:fcall, :lambda],
283
+ [:masgn, nil, [:splat], nil],
284
+ [:nil]])
285
+
286
+ add_tests("lambda_args_anon_star_block", # FIX: think this is wrong
287
+ "RawParseTree" => [:iter,
288
+ [:fcall, :lambda],
289
+ [:block_pass,
290
+ [:dasgn_curr, :block],
291
+ [:masgn, nil, [:splat], nil]],
292
+ [:dvar, :block]])
293
+
294
+ add_tests("lambda_args_block",
295
+ "RawParseTree" => [:iter,
296
+ [:fcall, :lambda],
297
+ [:block_pass, [:dasgn_curr, :block]],
298
+ [:dvar, :block]])
299
+
300
+ add_tests("lambda_args_norm_anon_star", # FIX: think this is wrong
301
+ "RawParseTree" => [:iter,
302
+ [:fcall, :lambda],
303
+ [:masgn,
304
+ [:array, [:dasgn_curr, :a]], [:splat], nil],
305
+ [:dvar, :a]])
306
+
307
+ add_tests("lambda_args_norm_anon_star_block", # FIX: think this is wrong
308
+ "RawParseTree" => [:iter,
309
+ [:fcall, :lambda],
310
+ [:block_pass,
311
+ [:dasgn_curr, :block],
312
+ [:masgn,
313
+ [:array, [:dasgn_curr, :a]], [:splat], nil]],
314
+ [:dvar, :block]])
315
+
316
+ add_tests("lambda_args_norm_block", # FIX: think this is wrong
317
+ "RawParseTree" => [:iter,
318
+ [:fcall, :lambda],
319
+ [:block_pass,
320
+ [:dasgn_curr, :block],
321
+ [:masgn,
322
+ [:array, [:dasgn_curr, :a]], nil, nil]],
323
+ [:dvar, :block]])
324
+
325
+ add_tests("lambda_args_norm_comma", # FIX: think this is wrong
326
+ "RawParseTree" => [:iter,
327
+ [:fcall, :lambda],
328
+ [:masgn, [:array, [:dasgn_curr, :a]], nil, nil],
329
+ [:dvar, :a]])
330
+
331
+ add_tests("lambda_args_norm_comma2", # FIX: think this is wrong
332
+ "RawParseTree" => [:iter,
333
+ [:fcall, :lambda],
334
+ [:masgn,
335
+ [:array, [:dasgn_curr, :a], [:dasgn_curr, :b]],
336
+ nil, nil],
337
+ [:dvar, :a]])
338
+
339
+ add_tests("lambda_args_norm_star",
340
+ "RawParseTree" => [:iter,
341
+ [:fcall, :lambda],
342
+ [:masgn,
343
+ [:array, [:dasgn_curr, :a]],
344
+ [:dasgn_curr, :star], nil],
345
+ [:dvar, :star]])
346
+
347
+ add_tests("lambda_args_norm_star_block",
348
+ "RawParseTree" => [:iter,
349
+ [:fcall, :lambda],
350
+ [:block_pass,
351
+ [:dasgn_curr, :block],
352
+ [:masgn,
353
+ [:array, [:dasgn_curr, :a]],
354
+ [:dasgn_curr, :star], nil]],
355
+ [:dvar, :block]])
356
+
357
+ add_tests("lambda_args_star_block",
358
+ "RawParseTree" => [:iter,
359
+ [:fcall, :lambda],
360
+ [:block_pass,
361
+ [:dasgn_curr, :block],
362
+ [:masgn, nil, [:dasgn_curr, :star], nil]],
363
+ [:dvar, :block]])
364
+
365
+ add_tests("block_stmt_after",
366
+ "RawParseTree" => [:defn, :f,
367
+ [:scope,
368
+ [:block,
369
+ [:args],
370
+ [:rescue,
371
+ [:vcall, :b],
372
+ [:resbody, nil, [:vcall, :c]]],
373
+ [:vcall, :d]]]])
374
+
375
+ add_tests("block_stmt_after_mri_verbose_flag",
376
+ "RawParseTree" => [:defn, :f,
377
+ [:scope,
378
+ [:block,
379
+ [:args],
380
+ [:rescue, # no begin
381
+ [:vcall, :b],
382
+ [:resbody, nil, [:vcall, :c]]],
383
+ [:vcall, :d]]]])
384
+
385
+ add_tests("block_stmt_before",
386
+ "RawParseTree" => [:defn, :f,
387
+ [:scope,
388
+ [:block,
389
+ [:args],
390
+ [:vcall, :a],
391
+ [:rescue, [:vcall, :b],
392
+ [:resbody, nil, [:vcall, :c]]]]]])
393
+
394
+ copy_test_case "block_stmt_before", "RawParseTree"
395
+
396
+ add_tests("block_stmt_both",
397
+ "RawParseTree" => [:defn, :f,
398
+ [:scope,
399
+ [:block,
400
+ [:args],
401
+ [:vcall, :a],
402
+ [:rescue,
403
+ [:vcall, :b],
404
+ [:resbody,
405
+ nil,
406
+ [:vcall, :c]]],
407
+ [:vcall, :d]]]])
408
+
409
+ add_tests("block_stmt_both_mri_verbose_flag",
410
+ "RawParseTree" => [:defn, :f,
411
+ [:scope,
412
+ [:block,
413
+ [:args],
414
+ [:vcall, :a],
415
+ [:rescue, # no begin
416
+ [:vcall, :b],
417
+ [:resbody,
418
+ nil,
419
+ [:vcall, :c]]],
420
+ [:vcall, :d]]]])
421
+
422
+ add_tests("bmethod",
423
+ "RawParseTree" => [:defn, :unsplatted,
424
+ [:bmethod,
425
+ [:dasgn_curr, :x],
426
+ [:call, [:dvar, :x], :+, [:array, [:lit, 1]]]]])
427
+
428
+ add_tests("bmethod_noargs",
429
+ "RawParseTree" => [:defn, :bmethod_noargs,
430
+ [:bmethod,
431
+ nil,
432
+ [:call,
433
+ [:vcall, :x], :"+", [:array, [:lit, 1]]]]])
434
+
435
+ add_tests("bmethod_splat",
436
+ "RawParseTree" => [:defn, :splatted,
437
+ [:bmethod,
438
+ [:masgn, nil, [:dasgn_curr, :args], nil],
439
+ [:block,
440
+ [:dasgn_curr, :y,
441
+ [:call, [:dvar, :args], :first]],
442
+ [:call, [:dvar, :y], :+,
443
+ [:array, [:lit, 42]]]]]])
444
+
445
+ add_tests("break",
446
+ "RawParseTree" => [:iter,
447
+ [:fcall, :loop], nil,
448
+ [:if, [:true], [:break], nil]])
449
+
450
+ add_tests("break_arg",
451
+ "RawParseTree" => [:iter,
452
+ [:fcall, :loop], nil,
453
+ [:if, [:true], [:break, [:lit, 42]], nil]])
454
+
455
+ add_tests("call",
456
+ "RawParseTree" => [:call, [:self], :method])
457
+
458
+ add_tests("call_arglist",
459
+ "RawParseTree" => [:call, [:vcall, :o], :puts,
460
+ [:array, [:lit, 42]]])
461
+
462
+ add_tests("call_no_space_symbol",
463
+ "RawParseTree" => [:fcall, :foo, [:array, [:lit, :bar]]])
464
+
465
+ add_tests("ternary_symbol_no_spaces",
466
+ "RawParseTree" => [:if, [:lit, 1], [:lit, :x], [:lit, 1]])
467
+
468
+ add_tests("ternary_nil_no_space",
469
+ "RawParseTree" => [:if, [:lit, 1], [:nil], [:lit, 1]])
470
+
471
+ add_tests("call_arglist_hash",
472
+ "RawParseTree" => [:call,
473
+ [:vcall, :o], :m,
474
+ [:array,
475
+ [:hash,
476
+ [:lit, :a], [:lit, 1],
477
+ [:lit, :b], [:lit, 2]]]])
478
+
479
+ add_tests("call_arglist_norm_hash",
480
+ "RawParseTree" => [:call,
481
+ [:vcall, :o], :m,
482
+ [:array,
483
+ [:lit, 42],
484
+ [:hash,
485
+ [:lit, :a], [:lit, 1],
486
+ [:lit, :b], [:lit, 2]]]])
487
+
488
+ add_tests("call_arglist_norm_hash_splat",
489
+ "RawParseTree" => [:call,
490
+ [:vcall, :o], :m,
491
+ [:argscat,
492
+ [:array,
493
+ [:lit, 42],
494
+ [:hash,
495
+ [:lit, :a], [:lit, 1],
496
+ [:lit, :b], [:lit, 2]]],
497
+ [:vcall, :c]]])
498
+
499
+ add_tests("call_arglist_space",
500
+ "RawParseTree" => [:fcall, :a,
501
+ [:array, [:lit, 1], [:lit, 2], [:lit, 3]]])
502
+
503
+ add_tests("call_command",
504
+ "RawParseTree" => [:call, [:lit, 1], :b, [:array, [:vcall, :c]]])
505
+
506
+ add_tests("call_expr",
507
+ "RawParseTree" => [:call,
508
+ [:lasgn, :v,
509
+ [:call, [:lit, 1], :+, [:array, [:lit, 1]]]],
510
+ :zero?])
511
+
512
+ add_tests("call_index",
513
+ "RawParseTree" => [:block,
514
+ [:lasgn, :a, [:zarray]],
515
+ [:call, [:lvar, :a], :[], [:array, [:lit, 42]]]])
516
+
517
+ add_tests("call_index_no_args",
518
+ "RawParseTree" => [:call, [:vcall, :a], :[]])
519
+
520
+ add_tests("call_index_space",
521
+ "RawParseTree" => [:block,
522
+ [:lasgn, :a, [:zarray]],
523
+ [:call, [:lvar, :a], :[], [:array, [:lit, 42]]]])
524
+
525
+ add_tests("call_unary_neg",
526
+ "RawParseTree" => [:call,
527
+ [:call, [:lit, 2], :**, [:array, [:lit, 31]]],
528
+ :-@])
529
+
530
+ add_tests("case",
531
+ "RawParseTree" => [:block,
532
+ [:lasgn, :var, [:lit, 2]],
533
+ [:lasgn, :result, [:str, ""]],
534
+ [:case,
535
+ [:lvar, :var],
536
+ [:when,
537
+ [:array, [:lit, 1]],
538
+ [:block,
539
+ [:fcall, :puts,
540
+ [:array, [:str, "something"]]],
541
+ [:lasgn, :result, [:str, "red"]]]],
542
+ [:when,
543
+ [:array, [:lit, 2], [:lit, 3]],
544
+ [:lasgn, :result, [:str, "yellow"]]],
545
+ [:when, [:array, [:lit, 4]], nil],
546
+ [:lasgn, :result, [:str, "green"]]],
547
+ [:case,
548
+ [:lvar, :result],
549
+ [:when, [:array, [:str, "red"]],
550
+ [:lasgn, :var, [:lit, 1]]],
551
+ [:when, [:array, [:str, "yellow"]],
552
+ [:lasgn, :var, [:lit, 2]]],
553
+ [:when, [:array, [:str, "green"]],
554
+ [:lasgn, :var, [:lit, 3]]],
555
+ nil]])
556
+
557
+ add_tests("case_nested",
558
+ "RawParseTree" => [:block,
559
+ [:lasgn, :var1, [:lit, 1]],
560
+ [:lasgn, :var2, [:lit, 2]],
561
+ [:lasgn, :result, [:nil]],
562
+ [:case,
563
+ [:lvar, :var1],
564
+ [:when, [:array, [:lit, 1]],
565
+ [:case,
566
+ [:lvar, :var2],
567
+ [:when, [:array, [:lit, 1]],
568
+ [:lasgn, :result, [:lit, 1]]],
569
+ [:when, [:array, [:lit, 2]],
570
+ [:lasgn, :result, [:lit, 2]]],
571
+ [:lasgn, :result, [:lit, 3]]]],
572
+ [:when, [:array, [:lit, 2]],
573
+ [:case,
574
+ [:lvar, :var2],
575
+ [:when, [:array, [:lit, 1]],
576
+ [:lasgn, :result, [:lit, 4]]],
577
+ [:when, [:array, [:lit, 2]],
578
+ [:lasgn, :result, [:lit, 5]]],
579
+ [:lasgn, :result, [:lit, 6]]]],
580
+ [:lasgn, :result, [:lit, 7]]]])
581
+
582
+ add_tests("case_nested_inner_no_expr",
583
+ "RawParseTree" => [:case, [:vcall, :a],
584
+ [:when, [:array, [:vcall, :b]],
585
+ [:case, nil,
586
+ [:when,
587
+ [:array, [:and, [:vcall, :d], [:vcall, :e]]],
588
+ [:vcall, :f]],
589
+ nil]],
590
+ nil])
591
+
592
+ add_tests("case_no_expr",
593
+ "RawParseTree" => [:case, nil,
594
+ [:when,
595
+ [:array,
596
+ [:call, [:vcall, :a], :==,
597
+ [:array, [:lit, 1]]]],
598
+ [:lit, :a]],
599
+ [:when,
600
+ [:array,
601
+ [:call, [:vcall, :a], :==,
602
+ [:array, [:lit, 2]]]],
603
+ [:lit, :b]],
604
+ [:lit, :c]])
605
+
606
+ add_tests("case_splat",
607
+ "RawParseTree" => [:case, [:vcall, :a],
608
+ [:when,
609
+ [:array,
610
+ [:lit, :b], [:when, [:vcall, :c], nil]], # wtf?
611
+ [:vcall, :d]],
612
+ [:vcall, :e]])
613
+
614
+ add_tests("cdecl",
615
+ "RawParseTree" => [:cdecl, :X, [:lit, 42]])
616
+
617
+ add_tests("class_plain",
618
+ "RawParseTree" => [:class,
619
+ :X,
620
+ nil,
621
+ [:scope,
622
+ [:block,
623
+ [:fcall, :puts,
624
+ [:array,
625
+ [:call, [:lit, 1], :+,
626
+ [:array, [:lit, 1]]]]],
627
+ [:defn, :blah,
628
+ [:scope,
629
+ [:block,
630
+ [:args],
631
+ [:fcall, :puts,
632
+ [:array, [:str, "hello"]]]]]]]]])
633
+
634
+ add_tests("class_scoped",
635
+ "RawParseTree" => [:class, [:colon2, [:const, :X], :Y], nil,
636
+ [:scope, [:vcall, :c]]])
637
+
638
+ add_tests("class_scoped3",
639
+ "RawParseTree" => [:class, [:colon3, :Y], nil,
640
+ [:scope, [:vcall, :c]]])
641
+
642
+ add_tests("class_super_array",
643
+ "RawParseTree" => [:class,
644
+ :X,
645
+ [:const, :Array],
646
+ [:scope]])
647
+
648
+ add_tests("class_super_expr",
649
+ "RawParseTree" => [:class,
650
+ :X,
651
+ [:vcall, :expr],
652
+ [:scope]])
653
+
654
+ add_tests("class_super_object",
655
+ "RawParseTree" => [:class,
656
+ :X,
657
+ [:const, :Object],
658
+ [:scope]])
659
+
660
+ add_tests("colon2",
661
+ "RawParseTree" => [:colon2, [:const, :X], :Y])
662
+
663
+ add_tests("colon3",
664
+ "RawParseTree" => [:colon3, :X])
665
+
666
+ add_tests("const",
667
+ "RawParseTree" => [:const, :X])
668
+
669
+ add_tests("constX",
670
+ "RawParseTree" => [:cdecl, :X, [:lit, 1]])
671
+
672
+ add_tests("constY",
673
+ "RawParseTree" => [:cdecl, [:colon3, :X], [:lit, 1]])
674
+
675
+ add_tests("constZ",
676
+ "RawParseTree" => [:cdecl, [:colon2, [:const, :X], :Y], [:lit, 1]])
677
+
678
+ add_tests("cvar",
679
+ "RawParseTree" => [:cvar, :@@x])
680
+
681
+ add_tests("cvasgn",
682
+ "RawParseTree" => [:defn, :x,
683
+ [:scope,
684
+ [:block, [:args],
685
+ [:cvasgn, :@@blah, [:lit, 1]]]]])
686
+
687
+ add_tests("cvasgn_cls_method",
688
+ "RawParseTree" => [:defs, [:self], :quiet_mode=,
689
+ [:scope,
690
+ [:block,
691
+ [:args, :boolean],
692
+ [:cvasgn, :@@quiet_mode, [:lvar, :boolean]]]]])
693
+
694
+ add_tests("cvdecl",
695
+ "RawParseTree" => [:class, :X, nil,
696
+ [:scope, [:cvdecl, :@@blah, [:lit, 1]]]])
697
+
698
+ add_tests("dasgn_0",
699
+ "RawParseTree" => [:iter,
700
+ [:call, [:vcall, :a], :each],
701
+ [:dasgn_curr, :x],
702
+ [:if, [:true],
703
+ [:iter,
704
+ [:call, [:vcall, :b], :each],
705
+ [:dasgn_curr, :y],
706
+ [:dasgn, :x,
707
+ [:call, [:dvar, :x], :+,
708
+ [:array, [:lit, 1]]]]],
709
+ nil]])
710
+
711
+ add_tests("dasgn_1",
712
+ "RawParseTree" => [:iter,
713
+ [:call, [:vcall, :a], :each],
714
+ [:dasgn_curr, :x],
715
+ [:if, [:true],
716
+ [:iter,
717
+ [:call, [:vcall, :b], :each],
718
+ [:dasgn_curr, :y],
719
+ [:dasgn_curr, :c,
720
+ [:call, [:dvar, :c], :+,
721
+ [:array, [:lit, 1]]]]],
722
+ nil]])
723
+
724
+ add_tests("dasgn_2",
725
+ "RawParseTree" => [:iter,
726
+ [:call, [:vcall, :a], :each],
727
+ [:dasgn_curr, :x],
728
+ [:if, [:true],
729
+ [:block,
730
+ [:dasgn_curr, :c, [:lit, 0]],
731
+ [:iter,
732
+ [:call, [:vcall, :b], :each],
733
+ [:dasgn_curr, :y],
734
+ [:dasgn, :c,
735
+ [:call, [:dvar, :c], :+,
736
+ [:array, [:lit, 1]]]]]],
737
+ nil]])
738
+
739
+ add_tests("dasgn_curr",
740
+ "RawParseTree" => [:iter,
741
+ [:call, [:vcall, :data], :each],
742
+ [:masgn,
743
+ [:array, [:dasgn_curr, :x], [:dasgn_curr, :y]],
744
+ nil, nil],
745
+ [:block,
746
+ [:dasgn_curr, :a, [:lit, 1]],
747
+ [:dasgn_curr, :b, [:dvar, :a]],
748
+ [:dasgn_curr, :b,
749
+ [:dasgn_curr, :a, [:dvar, :x]]]]])
750
+
751
+ add_tests("dasgn_icky",
752
+ "RawParseTree" => [:iter,
753
+ [:fcall, :a],
754
+ nil,
755
+ [:block,
756
+ [:dasgn_curr, :v, [:nil]],
757
+ [:iter,
758
+ [:fcall, :assert_block,
759
+ [:array, [:vcall, :full_message]]],
760
+ nil,
761
+ [:rescue,
762
+ [:yield],
763
+ [:resbody,
764
+ [:array, [:const, :Exception]],
765
+ [:block,
766
+ [:dasgn, :v,
767
+ [:gvar, :$!]], [:break]]]]]]])
768
+
769
+ add_tests("dasgn_mixed",
770
+ "RawParseTree" => [:block,
771
+ [:lasgn, :t, [:lit, 0]],
772
+ [:iter,
773
+ [:call, [:vcall, :ns], :each],
774
+ [:dasgn_curr, :n],
775
+ [:lasgn, :t,
776
+ [:call, [:lvar, :t], :+,
777
+ [:array, [:dvar, :n]]]]]])
778
+
779
+ add_tests("defined",
780
+ "RawParseTree" => [:defined, [:gvar, :$x]])
781
+
782
+ # TODO: make all the defn_args* p their arglist
783
+ add_tests("defn_args_block",
784
+ "RawParseTree" => [:defn, :f,
785
+ [:scope,
786
+ [:block,
787
+ [:args],
788
+ [:block_arg, :block],
789
+ [:nil]]]])
790
+
791
+ add_tests("defn_args_mand",
792
+ "RawParseTree" => [:defn, :f,
793
+ [:scope,
794
+ [:block,
795
+ [:args, :mand],
796
+ [:nil]]]])
797
+
798
+ add_tests("defn_args_mand_block",
799
+ "RawParseTree" => [:defn, :f,
800
+ [:scope,
801
+ [:block,
802
+ [:args, :mand],
803
+ [:block_arg, :block],
804
+ [:nil]]]])
805
+
806
+ add_tests("defn_args_mand_opt",
807
+ "RawParseTree" => [:defn, :f,
808
+ [:scope,
809
+ [:block,
810
+ [:args, :mand, :opt,
811
+ [:block,
812
+ [:lasgn, :opt, [:lit, 42]]]],
813
+ [:nil]]]])
814
+
815
+ add_tests("defn_args_mand_opt_block",
816
+ "RawParseTree" => [:defn, :f,
817
+ [:scope,
818
+ [:block,
819
+ [:args, :mand, :opt,
820
+ [:block,
821
+ [:lasgn, :opt, [:lit, 42]]]],
822
+ [:block_arg, :block],
823
+ [:nil]]]])
824
+
825
+ add_tests("defn_args_mand_opt_splat",
826
+ "RawParseTree" => [:defn, :f,
827
+ [:scope,
828
+ [:block,
829
+ [:args, :mand, :opt, :"*rest",
830
+ [:block,
831
+ [:lasgn, :opt, [:lit, 42]]]],
832
+ [:nil]]]])
833
+
834
+ add_tests("defn_args_mand_opt_splat_block",
835
+ "RawParseTree" => [:defn, :f,
836
+ [:scope,
837
+ [:block,
838
+ [:args, :mand, :opt, :"*rest",
839
+ [:block,
840
+ [:lasgn, :opt, [:lit, 42]]]],
841
+ [:block_arg, :block],
842
+ [:nil]]]])
843
+
844
+ add_tests("defn_args_mand_opt_splat_no_name",
845
+ "RawParseTree" => [:defn, :x,
846
+ [:scope,
847
+ [:block,
848
+ [:args, :a, :b, :"*",
849
+ [:block, [:lasgn, :b, [:lit, 42]]]],
850
+ [:nil]]]])
851
+
852
+ add_tests("defn_args_mand_splat",
853
+ "RawParseTree" => [:defn, :f,
854
+ [:scope,
855
+ [:block,
856
+ [:args, :mand, :"*rest"],
857
+ [:nil]]]])
858
+
859
+ add_tests("defn_args_mand_splat_block",
860
+ "RawParseTree" => [:defn, :f,
861
+ [:scope,
862
+ [:block,
863
+ [:args, :mand, :"*rest"],
864
+ [:block_arg, :block],
865
+ [:nil]]]])
866
+
867
+ add_tests("defn_args_mand_splat_no_name",
868
+ "RawParseTree" => [:defn, :x,
869
+ [:scope,
870
+ [:block,
871
+ [:args, :a, :"*args"],
872
+ [:fcall, :p,
873
+ [:array, [:lvar, :a], [:lvar, :args]]]]]])
874
+
875
+ add_tests("defn_args_none",
876
+ "RawParseTree" => [:defn, :empty,
877
+ [:scope, [:block, [:args], [:nil]]]])
878
+
879
+ add_tests("defn_args_opt",
880
+ "RawParseTree" => [:defn, :f,
881
+ [:scope,
882
+ [:block,
883
+ [:args, :opt,
884
+ [:block,
885
+ [:lasgn, :opt, [:lit, 42]]]],
886
+ [:nil]]]])
887
+
888
+ add_tests("defn_args_opt_block",
889
+ "RawParseTree" => [:defn, :f,
890
+ [:scope,
891
+ [:block,
892
+ [:args, :opt,
893
+ [:block,
894
+ [:lasgn, :opt, [:lit, 42]]]],
895
+ [:block_arg, :block],
896
+ [:nil]]]])
897
+
898
+ add_tests("defn_args_opt_splat",
899
+ "RawParseTree" => [:defn, :f,
900
+ [:scope,
901
+ [:block,
902
+ [:args, :opt, :"*rest",
903
+ [:block,
904
+ [:lasgn, :opt, [:lit, 42]]]],
905
+ [:nil]]]])
906
+
907
+ add_tests("defn_args_opt_splat_block",
908
+ "RawParseTree" => [:defn, :f,
909
+ [:scope,
910
+ [:block,
911
+ [:args, :opt, :"*rest",
912
+ [:block,
913
+ [:lasgn, :opt, [:lit, 42]]]],
914
+ [:block_arg, :block],
915
+ [:nil]]]])
916
+
917
+ add_tests("defn_args_opt_splat_no_name",
918
+ "RawParseTree" => [:defn, :x,
919
+ [:scope,
920
+ [:block,
921
+ [:args, :b, :"*",
922
+ [:block, [:lasgn, :b, [:lit, 42]]]],
923
+ [:nil]]]])
924
+
925
+ add_tests("defn_args_splat",
926
+ "RawParseTree" => [:defn, :f,
927
+ [:scope,
928
+ [:block,
929
+ [:args, :"*rest"],
930
+ [:nil]]]])
931
+
932
+ add_tests("defn_args_splat_no_name",
933
+ "RawParseTree" => [:defn, :x,
934
+ [:scope,
935
+ [:block,
936
+ [:args, :"*"],
937
+ [:nil]]]])
938
+
939
+ add_tests("defn_or",
940
+ "RawParseTree" => [:defn, :|,
941
+ [:scope, [:block, [:args, :o], [:nil]]]])
942
+
943
+ add_tests("defn_rescue",
944
+ "RawParseTree" => [:defn, :eql?,
945
+ [:scope,
946
+ [:block,
947
+ [:args, :resource],
948
+ [:rescue,
949
+ [:call,
950
+ [:call, [:self], :uuid],
951
+ :==,
952
+ [:array,
953
+ [:call, [:lvar, :resource], :uuid]]],
954
+ [:resbody, nil, [:false]]]]]])
955
+
956
+ add_tests("defn_rescue_mri_verbose_flag",
957
+ "RawParseTree" => [:defn, :eql?,
958
+ [:scope,
959
+ [:block,
960
+ [:args, :resource],
961
+ [:rescue,
962
+ [:call,
963
+ [:call, [:self], :uuid],
964
+ :==,
965
+ [:array,
966
+ [:call, [:lvar, :resource], :uuid]]],
967
+ [:resbody, nil, [:false]]]]]])
968
+
969
+ add_tests("defn_something_eh",
970
+ "RawParseTree" => [:defn, :something?,
971
+ [:scope, [:block, [:args], [:nil]]]])
972
+
973
+ add_tests("defn_splat_no_name",
974
+ "RawParseTree" => [:defn, :x,
975
+ [:scope,
976
+ [:block,
977
+ [:args, :a, :"*"],
978
+ [:fcall, :p,
979
+ [:array, [:lvar, :a]]]]]])
980
+
981
+ add_tests("defn_zarray",
982
+ "RawParseTree" => [:defn, :zarray,
983
+ [:scope,
984
+ [:block, [:args],
985
+ [:lasgn, :a, [:zarray]],
986
+ [:return, [:lvar, :a]]]]])
987
+
988
+ add_tests("defs",
989
+ "RawParseTree" => [:defs, [:self], :x,
990
+ [:scope,
991
+ [:block,
992
+ [:args, :y],
993
+ [:call, [:lvar, :y], :+,
994
+ [:array, [:lit, 1]]]]]])
995
+
996
+ add_tests("defs_empty",
997
+ "RawParseTree" => [:defs, [:self], :empty,
998
+ [:scope, [:args]]])
999
+
1000
+ add_tests("defs_empty_args",
1001
+ "RawParseTree" => [:defs, [:self], :empty,
1002
+ [:scope, [:args, :*]]])
1003
+
1004
+ add_tests("defs_expr_wtf",
1005
+ "RawParseTree" => [:defs,
1006
+ [:call, [:vcall, :a], :b],
1007
+ :empty,
1008
+ [:scope, [:args, :*]]])
1009
+
1010
+ add_tests("dmethod",
1011
+ "RawParseTree" => [:defn, :dmethod_added,
1012
+ [:dmethod,
1013
+ :a_method,
1014
+ [:scope,
1015
+ [:block,
1016
+ [:args, :x],
1017
+ [:call, [:lvar, :x], :+,
1018
+ [:array, [:lit, 1]]]]]]])
1019
+
1020
+ add_tests("dot2",
1021
+ "RawParseTree" => [:dot2, [:vcall, :a], [:vcall, :b]])
1022
+
1023
+ add_tests("dot3",
1024
+ "RawParseTree" => [:dot3, [:vcall, :a], [:vcall, :b]])
1025
+
1026
+ add_tests("dregx",
1027
+ "RawParseTree" => [:dregx, "x",
1028
+ [:evstr,
1029
+ [:call, [:lit, 1], :+, [:array, [:lit, 1]]]],
1030
+ [:str, "y"]])
1031
+
1032
+ add_tests("dregx_interp",
1033
+ "RawParseTree" => [:dregx, '', [:evstr, [:ivar, :@rakefile]]])
1034
+
1035
+ add_tests("dregx_interp_empty",
1036
+ "RawParseTree" => [:dregx, 'a', [:evstr], [:str, "b"]])
1037
+
1038
+ add_tests("dregx_n",
1039
+ "RawParseTree" => [:dregx, '', [:evstr, [:lit, 1]], /x/n.options])
1040
+
1041
+ add_tests("dregx_once",
1042
+ "RawParseTree" => [:dregx_once, "x",
1043
+ [:evstr,
1044
+ [:call, [:lit, 1], :+, [:array, [:lit, 1]]]],
1045
+ [:str, "y"]])
1046
+
1047
+ add_tests("dregx_once_n_interp",
1048
+ "RawParseTree" => [:dregx_once, '',
1049
+ [:evstr, [:const, :IAC]],
1050
+ [:evstr, [:const, :SB]], /x/n.options])
1051
+
1052
+ add_tests("dstr",
1053
+ "RawParseTree" => [:block,
1054
+ [:lasgn, :argl, [:lit, 1]],
1055
+ [:dstr, "x", [:evstr, [:lvar, :argl]],
1056
+ [:str, "y"]]])
1057
+
1058
+ add_tests("dstr_2",
1059
+ "RawParseTree" => [:block,
1060
+ [:lasgn, :argl, [:lit, 1]],
1061
+ [:dstr,
1062
+ "x",
1063
+ [:evstr,
1064
+ [:call, [:str, "%.2f"], :%,
1065
+ [:array, [:lit, 3.14159]]]],
1066
+ [:str, "y"]]])
1067
+
1068
+ add_tests("dstr_3",
1069
+ "RawParseTree" => [:block,
1070
+ [:lasgn, :max, [:lit, 2]],
1071
+ [:lasgn, :argl, [:lit, 1]],
1072
+ [:dstr, "x",
1073
+ [:evstr,
1074
+ [:call,
1075
+ [:dstr, "%.",
1076
+ [:evstr, [:lvar, :max]],
1077
+ [:str, "f"]],
1078
+ :%,
1079
+ [:array, [:lit, 3.14159]]]],
1080
+ [:str, "y"]]])
1081
+
1082
+ add_tests("dstr_concat",
1083
+ "RawParseTree" => [:dstr,
1084
+ "",
1085
+ [:evstr, [:lit, 22]],
1086
+ [:str, "aa"],
1087
+ [:str, "cd"],
1088
+ [:evstr, [:lit, 44]],
1089
+ [:str, "55"],
1090
+ [:evstr, [:lit, 66]]])
1091
+
1092
+ add_tests("dstr_gross",
1093
+ "RawParseTree" => [:dstr, "a ",
1094
+ [:evstr, [:gvar, :$global]],
1095
+ [:str, " b "],
1096
+ [:evstr, [:ivar, :@ivar]],
1097
+ [:str, " c "],
1098
+ [:evstr, [:cvar, :@@cvar]],
1099
+ [:str, " d"]])
1100
+
1101
+ add_tests("dstr_heredoc_expand",
1102
+ "RawParseTree" => [:dstr, " blah\n",
1103
+ [:evstr, [:call, [:lit, 1], :+,
1104
+ [:array, [:lit, 1]]]],
1105
+ [:str, "blah\n"]])
1106
+
1107
+ add_tests("dstr_heredoc_windoze_sucks",
1108
+ "RawParseTree" => [:dstr,
1109
+ 'def test_',
1110
+ [:evstr, [:vcall, :action]],
1111
+ [:str, "_valid_feed\n"]])
1112
+
1113
+ add_tests("dstr_heredoc_yet_again",
1114
+ "RawParseTree" => [:dstr, "s1 '",
1115
+ [:evstr, [:const, :RUBY_PLATFORM]],
1116
+ [:str, "' s2\n"],
1117
+ [:str, "(string)"],
1118
+ [:str, "\n"]])
1119
+
1120
+ add_tests("dstr_nest",
1121
+ "RawParseTree" => [:dstr, "before [",
1122
+ [:evstr, [:vcall, :nest]], [:str, "] after"]])
1123
+
1124
+ add_tests("dstr_str_lit_start",
1125
+ "RawParseTree" => [:dstr,
1126
+ "blah(string):",
1127
+ [:evstr, [:lit, 1]],
1128
+ [:str, ": warning: "],
1129
+ [:evstr, [:call, [:gvar, :$!], :message]],
1130
+ [:str, " ("],
1131
+ [:evstr, [:call, [:gvar, :$!], :class]],
1132
+ [:str, ")"]])
1133
+
1134
+ add_tests("dstr_the_revenge",
1135
+ "RawParseTree" => [:dstr,
1136
+ "before ",
1137
+ [:evstr, [:vcall, :from]],
1138
+ [:str, " middle "],
1139
+ [:evstr, [:vcall, :to]],
1140
+ [:str, " ("],
1141
+ [:str, "(string)"],
1142
+ [:str, ":"],
1143
+ [:evstr, [:lit, 1]],
1144
+ [:str, ")"]])
1145
+
1146
+ add_tests("dsym",
1147
+ "RawParseTree" => [:dsym, "x",
1148
+ [:evstr, [:call, [:lit, 1], :+,
1149
+ [:array, [:lit, 1]]]], [:str, "y"]])
1150
+
1151
+ add_tests("dxstr",
1152
+ "RawParseTree" => [:block,
1153
+ [:lasgn, :t, [:lit, 5]],
1154
+ [:dxstr, 'touch ', [:evstr, [:lvar, :t]]]])
1155
+
1156
+ add_tests("ensure",
1157
+ "RawParseTree" => [:ensure,
1158
+ [:rescue,
1159
+ [:call, [:lit, 1], :+, [:array, [:lit, 1]]],
1160
+ [:resbody,
1161
+ [:array, [:const, :SyntaxError]],
1162
+ [:block,
1163
+ [:lasgn, :e1, [:gvar, :$!]], [:lit, 2]],
1164
+ [:resbody,
1165
+ [:array, [:const, :Exception]],
1166
+ [:block,
1167
+ [:lasgn, :e2, [:gvar, :$!]], [:lit, 3]]]],
1168
+ [:lit, 4]],
1169
+ [:lit, 5]])
1170
+
1171
+ add_tests("false",
1172
+ "RawParseTree" => [:false])
1173
+
1174
+ add_tests("fbody",
1175
+ "RawParseTree" => [:defn, :an_alias,
1176
+ [:fbody,
1177
+ [:scope,
1178
+ [:block,
1179
+ [:args, :x],
1180
+ [:call, [:lvar, :x], :+,
1181
+ [:array, [:lit, 1]]]]]]])
1182
+
1183
+ add_tests("fcall_arglist",
1184
+ "RawParseTree" => [:fcall, :m, [:array, [:lit, 42]]])
1185
+
1186
+ add_tests("fcall_arglist_hash",
1187
+ "RawParseTree" => [:fcall, :m,
1188
+ [:array,
1189
+ [:hash,
1190
+ [:lit, :a], [:lit, 1],
1191
+ [:lit, :b], [:lit, 2]]]])
1192
+
1193
+ add_tests("fcall_arglist_norm_hash",
1194
+ "RawParseTree" => [:fcall, :m,
1195
+ [:array,
1196
+ [:lit, 42],
1197
+ [:hash,
1198
+ [:lit, :a], [:lit, 1],
1199
+ [:lit, :b], [:lit, 2]]]])
1200
+
1201
+ add_tests("fcall_arglist_norm_hash_splat",
1202
+ "RawParseTree" => [:fcall, :m,
1203
+ [:argscat,
1204
+ [:array,
1205
+ [:lit, 42],
1206
+ [:hash,
1207
+ [:lit, :a], [:lit, 1],
1208
+ [:lit, :b], [:lit, 2]]],
1209
+ [:vcall, :c]]])
1210
+
1211
+ add_tests("fcall_block",
1212
+ "RawParseTree" => [:iter,
1213
+ [:fcall, :a, [:array, [:lit, :b]]], nil,
1214
+ [:lit, :c]])
1215
+
1216
+ add_tests("fcall_index_space",
1217
+ "RawParseTree" => [:fcall, :a, [:array, [:array, [:lit, 42]]]])
1218
+
1219
+ add_tests("fcall_keyword",
1220
+ "RawParseTree" => [:if, [:fcall, :block_given?], [:lit, 42], nil])
1221
+
1222
+ add_tests("fcall_inside_parens",
1223
+ "RawParseTree" => [:fcall, :a, [:array, [:vcall, :b], [:vcall, :c]]])
1224
+
1225
+ add_tests("flip2",
1226
+ "RawParseTree" => [:lasgn,
1227
+ :x,
1228
+ [:if,
1229
+ [:flip2,
1230
+ [:call,
1231
+ [:call, [:vcall, :i], :%,
1232
+ [:array, [:lit, 4]]],
1233
+ :==,
1234
+ [:array, [:lit, 0]]],
1235
+ [:call,
1236
+ [:call, [:vcall, :i], :%,
1237
+ [:array, [:lit, 3]]],
1238
+ :==,
1239
+ [:array, [:lit, 0]]]],
1240
+ [:vcall, :i],
1241
+ [:nil]]])
1242
+
1243
+ add_tests("flip2_method",
1244
+ "RawParseTree" => [:if,
1245
+ [:flip2,
1246
+ [:call, [:lit, 1], :==,
1247
+ [:array, [:gvar, :$.]]],
1248
+ [:call, [:lit, 2], :a?,
1249
+ [:array, [:vcall, :b]]]],
1250
+ [:nil],
1251
+ nil])
1252
+
1253
+ add_tests("flip3",
1254
+ "RawParseTree" => [:lasgn,
1255
+ :x,
1256
+ [:if,
1257
+ [:flip3,
1258
+ [:call,
1259
+ [:call, [:vcall, :i], :%,
1260
+ [:array, [:lit, 4]]],
1261
+ :==,
1262
+ [:array, [:lit, 0]]],
1263
+ [:call,
1264
+ [:call, [:vcall, :i], :%,
1265
+ [:array, [:lit, 3]]],
1266
+ :==,
1267
+ [:array, [:lit, 0]]]],
1268
+ [:vcall, :i],
1269
+ [:nil]]])
1270
+
1271
+ add_tests("for",
1272
+ "RawParseTree" => [:for,
1273
+ [:vcall, :ary],
1274
+ [:lasgn, :o],
1275
+ [:fcall, :puts, [:array, [:lvar, :o]]]])
1276
+
1277
+ add_tests("for_no_body",
1278
+ "RawParseTree" => [:for,
1279
+ [:dot2, [:lit, 0], [:vcall, :max]],
1280
+ [:lasgn, :i]])
1281
+
1282
+ add_tests("gasgn",
1283
+ "RawParseTree" => [:gasgn, :$x, [:lit, 42]])
1284
+
1285
+ add_tests("global",
1286
+ "RawParseTree" => [:gvar, :$stderr])
1287
+
1288
+ add_tests("gvar",
1289
+ "RawParseTree" => [:gvar, :$x])
1290
+
1291
+ add_tests("gvar_underscore",
1292
+ "RawParseTree" => [:gvar, :$_])
1293
+
1294
+ add_tests("gvar_underscore_blah",
1295
+ "RawParseTree" => [:gvar, :$__blah])
1296
+
1297
+ add_tests("hash",
1298
+ "RawParseTree" => [:hash,
1299
+ [:lit, 1], [:lit, 2],
1300
+ [:lit, 3], [:lit, 4]])
1301
+
1302
+ add_tests("hash_rescue",
1303
+ "RawParseTree" => [:hash,
1304
+ [:lit, 1],
1305
+ [:rescue,
1306
+ [:lit, 2],
1307
+ [:resbody, nil, [:lit, 3]]]])
1308
+
1309
+ add_tests("iasgn",
1310
+ "RawParseTree" => [:iasgn, :@a, [:lit, 4]])
1311
+
1312
+ add_tests("if_block_condition",
1313
+ "RawParseTree" => [:if,
1314
+ [:block,
1315
+ [:lasgn, :x, [:lit, 5]],
1316
+ [:call,
1317
+ [:lvar, :x],
1318
+ :+,
1319
+ [:array, [:lit, 1]]]],
1320
+ [:nil],
1321
+ nil])
1322
+
1323
+ add_tests("if_lasgn_short",
1324
+ "RawParseTree" => [:if,
1325
+ [:lasgn, :x,
1326
+ [:call, [:vcall, :obj], :x]],
1327
+ [:call,
1328
+ [:lvar, :x], :do_it],
1329
+ nil])
1330
+
1331
+ add_tests("if_nested",
1332
+ "RawParseTree" => [:if, [:true], nil,
1333
+ [:if, [:false], [:return], nil]])
1334
+
1335
+ add_tests("if_post",
1336
+ "RawParseTree" => [:if, [:vcall, :b], [:vcall, :a], nil])
1337
+
1338
+ add_tests("if_post_not",
1339
+ "RawParseTree" => [:if, [:vcall, :b], nil, [:vcall, :a]])
1340
+
1341
+ add_tests("if_pre",
1342
+ "RawParseTree" => [:if, [:vcall, :b], [:vcall, :a], nil])
1343
+
1344
+ add_tests("if_pre_not",
1345
+ "RawParseTree" => [:if, [:vcall, :b], nil, [:vcall, :a]])
1346
+
1347
+ add_tests("iter_call_arglist_space",
1348
+ "RawParseTree" => [:iter,
1349
+ [:fcall, :a, [:array, [:lit, 1]]],
1350
+ [:dasgn_curr, :c],
1351
+ [:vcall, :d]])
1352
+
1353
+ add_tests("iter_dasgn_curr_dasgn_madness",
1354
+ "RawParseTree" => [:iter,
1355
+ [:call, [:vcall, :as], :each],
1356
+ [:dasgn_curr, :a],
1357
+ [:dasgn_curr,
1358
+ :b,
1359
+ [:call,
1360
+ [:dvar, :b],
1361
+ :+,
1362
+ [:array,
1363
+ [:call, [:dvar, :a], :b,
1364
+ [:array, [:false]]]]]]])
1365
+
1366
+ add_tests("iter_downto",
1367
+ "RawParseTree" => [:iter,
1368
+ [:call, [:lit, 3], :downto, [:array, [:lit, 1]]],
1369
+ [:dasgn_curr, :n],
1370
+ [:fcall, :puts,
1371
+ [:array, [:call, [:dvar, :n], :to_s]]]])
1372
+
1373
+ add_tests("iter_each_lvar",
1374
+ "RawParseTree" => [:block,
1375
+ [:lasgn, :array,
1376
+ [:array, [:lit, 1], [:lit, 2], [:lit, 3]]],
1377
+ [:iter,
1378
+ [:call, [:lvar, :array], :each],
1379
+ [:dasgn_curr, :x],
1380
+ [:fcall, :puts,
1381
+ [:array, [:call, [:dvar, :x], :to_s]]]]])
1382
+
1383
+ add_tests("iter_each_nested",
1384
+ "RawParseTree" => [:block,
1385
+ [:lasgn, :array1,
1386
+ [:array, [:lit, 1], [:lit, 2], [:lit, 3]]],
1387
+ [:lasgn, :array2,
1388
+ [:array,
1389
+ [:lit, 4], [:lit, 5], [:lit, 6], [:lit, 7]]],
1390
+ [:iter,
1391
+ [:call,
1392
+ [:lvar, :array1], :each],
1393
+ [:dasgn_curr, :x],
1394
+ [:iter,
1395
+ [:call,
1396
+ [:lvar, :array2], :each],
1397
+ [:dasgn_curr, :y],
1398
+ [:block,
1399
+ [:fcall, :puts,
1400
+ [:array, [:call, [:dvar, :x], :to_s]]],
1401
+ [:fcall, :puts,
1402
+ [:array, [:call, [:dvar, :y], :to_s]]]]]]])
1403
+
1404
+ add_tests("iter_loop_empty",
1405
+ "RawParseTree" => [:iter, [:fcall, :loop], nil])
1406
+
1407
+ add_tests("iter_masgn_2",
1408
+ "RawParseTree" => [:iter,
1409
+ [:fcall, :a],
1410
+ [:masgn,
1411
+ [:array, [:dasgn_curr, :b], [:dasgn_curr, :c]],
1412
+ nil, nil],
1413
+ [:fcall, :p, [:array, [:dvar, :c]]]])
1414
+
1415
+ add_tests("iter_masgn_args_splat",
1416
+ "RawParseTree" => [:iter,
1417
+ [:fcall, :a],
1418
+ [:masgn,
1419
+ [:array, [:dasgn_curr, :b], [:dasgn_curr, :c]],
1420
+ [:dasgn_curr, :d], nil],
1421
+ [:fcall, :p, [:array, [:dvar, :c]]]])
1422
+
1423
+ add_tests("iter_masgn_args_splat_no_name",
1424
+ "RawParseTree" => [:iter,
1425
+ [:fcall, :a],
1426
+ [:masgn,
1427
+ [:array, [:dasgn_curr, :b], [:dasgn_curr, :c]],
1428
+ [:splat], nil],
1429
+ [:fcall, :p, [:array, [:dvar, :c]]]])
1430
+
1431
+ add_tests("iter_masgn_splat",
1432
+ "RawParseTree" => [:iter,
1433
+ [:fcall, :a],
1434
+ [:masgn, nil, [:dasgn_curr, :c], nil],
1435
+ [:fcall, :p, [:array, [:dvar, :c]]]])
1436
+
1437
+ add_tests("iter_masgn_splat_no_name",
1438
+ "RawParseTree" => [:iter,
1439
+ [:fcall, :a],
1440
+ [:masgn, nil, [:splat], nil],
1441
+ [:fcall, :p, [:array, [:vcall, :c]]]])
1442
+
1443
+ add_tests("iter_shadowed_var",
1444
+ "RawParseTree" => [:iter,
1445
+ [:fcall, :a],
1446
+ [:dasgn_curr, :x],
1447
+ [:iter,
1448
+ [:fcall, :b],
1449
+ [:dasgn, :x],
1450
+ [:fcall, :puts, [:array, [:dvar, :x]]]]])
1451
+
1452
+ add_tests("iter_upto",
1453
+ "RawParseTree" => [:iter,
1454
+ [:call, [:lit, 1], :upto, [:array, [:lit, 3]]],
1455
+ [:dasgn_curr, :n],
1456
+ [:fcall, :puts,
1457
+ [:array, [:call, [:dvar, :n], :to_s]]]])
1458
+
1459
+ add_tests("iter_while",
1460
+ "RawParseTree" => [:block,
1461
+ [:lasgn, :argl, [:lit, 10]],
1462
+ [:while,
1463
+ [:call, [:lvar, :argl], :">=",
1464
+ [:array, [:lit, 1]]],
1465
+ [:block,
1466
+ [:fcall, :puts, [:array, [:str, "hello"]]],
1467
+ [:lasgn,
1468
+ :argl,
1469
+ [:call, [:lvar, :argl],
1470
+ :"-", [:array, [:lit, 1]]]]], true]])
1471
+
1472
+ add_tests("ivar",
1473
+ "RawParseTree" => [:defn, :reader, [:ivar, :@reader]])
1474
+
1475
+ add_tests("lasgn_array",
1476
+ "RawParseTree" => [:lasgn, :var,
1477
+ [:array,
1478
+ [:str, "foo"],
1479
+ [:str, "bar"]]])
1480
+
1481
+ add_tests("lasgn_call",
1482
+ "RawParseTree" => [:lasgn, :c, [:call, [:lit, 2], :+,
1483
+ [:array, [:lit, 3]]]])
1484
+
1485
+ add_tests("lit_bool_false",
1486
+ "RawParseTree" => [:false])
1487
+
1488
+ add_tests("lit_bool_true",
1489
+ "RawParseTree" => [:true])
1490
+
1491
+ add_tests("lit_float",
1492
+ "RawParseTree" => [:lit, 1.1])
1493
+
1494
+ add_tests("lit_long",
1495
+ "RawParseTree" => [:lit, 1])
1496
+
1497
+ add_tests("lit_long_negative",
1498
+ "RawParseTree" => [:lit, -1])
1499
+
1500
+ add_tests("lit_range2",
1501
+ "RawParseTree" => [:lit, 1..10])
1502
+
1503
+ add_tests("lit_range3",
1504
+ "RawParseTree" => [:lit, 1...10])
1505
+
1506
+ # TODO: discuss and decide which lit we like
1507
+ # it "converts a regexp to an sexp" do
1508
+ # "/blah/".to_sexp.should == s(:regex, "blah", 0)
1509
+ # "/blah/i".to_sexp.should == s(:regex, "blah", 1)
1510
+ # "/blah/u".to_sexp.should == s(:regex, "blah", 64)
1511
+ # end
1512
+
1513
+ add_tests("lit_regexp",
1514
+ "RawParseTree" => [:lit, /x/])
1515
+
1516
+ add_tests("lit_regexp_i_wwtt",
1517
+ "RawParseTree" => [:call, [:vcall, :str], :split,
1518
+ [:array, [:lit, //i]]])
1519
+
1520
+ add_tests("lit_regexp_n",
1521
+ "RawParseTree" => [:lit, /x/n])
1522
+
1523
+ add_tests("lit_regexp_once",
1524
+ "RawParseTree" => [:lit, /x/])
1525
+
1526
+ add_tests("lit_sym",
1527
+ "RawParseTree" => [:lit, :x])
1528
+
1529
+ add_tests("lit_sym_splat",
1530
+ "RawParseTree" => [:lit, :"*args"])
1531
+
1532
+ add_tests("lvar_def_boundary",
1533
+ "RawParseTree" => [:block,
1534
+ [:lasgn, :b, [:lit, 42]],
1535
+ [:defn, :a,
1536
+ [:scope,
1537
+ [:block,
1538
+ [:args],
1539
+ [:iter,
1540
+ [:fcall, :c],
1541
+ nil,
1542
+ [:rescue,
1543
+ [:vcall, :do_stuff],
1544
+ [:resbody,
1545
+ [:array, [:const, :RuntimeError]],
1546
+ [:block,
1547
+ [:dasgn_curr, :b, [:gvar, :$!]],
1548
+ [:fcall, :puts,
1549
+ [:array, [:dvar, :b]]]]]]]]]]])
1550
+
1551
+ add_tests("masgn",
1552
+ "RawParseTree" => [:masgn,
1553
+ [:array, [:lasgn, :a], [:lasgn, :b]], nil,
1554
+ [:array, [:vcall, :c], [:vcall, :d]]])
1555
+
1556
+ add_tests("masgn_argscat",
1557
+ "RawParseTree" => [:masgn,
1558
+ [:array, [:lasgn, :a], [:lasgn, :b]],
1559
+ [:lasgn, :c],
1560
+ [:argscat,
1561
+ [:array, [:lit, 1], [:lit, 2]],
1562
+ [:array, [:lit, 3], [:lit, 4]]]])
1563
+
1564
+ add_tests("masgn_attrasgn",
1565
+ "RawParseTree" => [:masgn,
1566
+ [:array, [:lasgn, :a],
1567
+ [:attrasgn, [:vcall, :b], :c=]], nil,
1568
+ [:array, [:vcall, :d], [:vcall, :e]]])
1569
+
1570
+ add_tests("masgn_attrasgn_array_rhs",
1571
+ "RawParseTree" => [:masgn,
1572
+ [:array,
1573
+ [:attrasgn, [:vcall, :a], :b=],
1574
+ [:attrasgn, [:vcall, :a], :c=],
1575
+ [:lasgn, :_]], nil,
1576
+ [:to_ary, [:vcall, :q]]])
1577
+
1578
+ add_tests("masgn_attrasgn_idx",
1579
+ "RawParseTree" => [:block,
1580
+ [:masgn,
1581
+ [:array,
1582
+ [:lasgn, :a], [:lasgn, :i], [:lasgn, :j]], nil,
1583
+ [:array, [:zarray], [:lit, 1], [:lit, 2]]],
1584
+ [:masgn,
1585
+ [:array,
1586
+ [:attrasgn,
1587
+ [:lvar, :a], :[]=, [:array, [:lvar, :i]]],
1588
+ [:attrasgn,
1589
+ [:lvar, :a], :[]=, [:array, [:lvar, :j]]]],
1590
+ nil,
1591
+ [:array,
1592
+ [:call, [:lvar, :a], :[],
1593
+ [:array, [:lvar, :j]]],
1594
+ [:call, [:lvar, :a], :[],
1595
+ [:array, [:lvar, :i]]]]]])
1596
+
1597
+ add_tests("masgn_cdecl",
1598
+ "RawParseTree" => [:masgn,
1599
+ [:array, [:cdecl, :A], [:cdecl, :B],
1600
+ [:cdecl, :C]], nil,
1601
+ [:array, [:lit, 1], [:lit, 2], [:lit, 3]]])
1602
+
1603
+
1604
+ add_tests("masgn_iasgn",
1605
+ "RawParseTree" => [:masgn,
1606
+ [:array, [:lasgn, :a], [:iasgn, :"@b"]], nil,
1607
+ [:array, [:vcall, :c], [:vcall, :d]]])
1608
+
1609
+ add_tests("masgn_masgn",
1610
+ "RawParseTree" => [:masgn,
1611
+ [:array,
1612
+ [:lasgn, :a],
1613
+ [:masgn,
1614
+ [:array,
1615
+ [:lasgn, :b],
1616
+ [:lasgn, :c]], nil, nil]],
1617
+ nil,
1618
+ [:to_ary,
1619
+ [:array,
1620
+ [:lit, 1],
1621
+ [:array,
1622
+ [:lit, 2],
1623
+ [:lit, 3]]]]])
1624
+
1625
+ add_tests("masgn_splat_lhs",
1626
+ "RawParseTree" => [:masgn,
1627
+ [:array, [:lasgn, :a], [:lasgn, :b]],
1628
+ [:lasgn, :c],
1629
+ [:array,
1630
+ [:vcall, :d], [:vcall, :e],
1631
+ [:vcall, :f], [:vcall, :g]]])
1632
+
1633
+ add_tests("masgn_splat_rhs_1",
1634
+ "RawParseTree" => [:masgn,
1635
+ [:array, [:lasgn, :a], [:lasgn, :b]],
1636
+ nil,
1637
+ [:splat, [:vcall, :c]]])
1638
+
1639
+ add_tests("masgn_splat_rhs_n",
1640
+ "RawParseTree" => [:masgn,
1641
+ [:array, [:lasgn, :a], [:lasgn, :b]],
1642
+ nil,
1643
+ [:argscat,
1644
+ [:array, [:vcall, :c], [:vcall, :d]],
1645
+ [:vcall, :e]]])
1646
+
1647
+ add_tests("masgn_splat_no_name_to_ary",
1648
+ "RawParseTree" => [:masgn,
1649
+ [:array, [:lasgn, :a], [:lasgn, :b]],
1650
+ [:splat],
1651
+ [:to_ary, [:vcall, :c]]])
1652
+
1653
+ add_tests("masgn_splat_no_name_trailing",
1654
+ "RawParseTree" => [:masgn,
1655
+ [:array, [:lasgn, :a], [:lasgn, :b]], nil,
1656
+ [:to_ary, [:vcall, :c]]]) # TODO: check this is right
1657
+
1658
+ add_tests("masgn_splat_to_ary",
1659
+ "RawParseTree" => [:masgn,
1660
+ [:array, [:lasgn, :a], [:lasgn, :b]],
1661
+ [:lasgn, :c],
1662
+ [:to_ary, [:vcall, :d]]])
1663
+
1664
+ add_tests("masgn_splat_to_ary2",
1665
+ "RawParseTree" => [:masgn,
1666
+ [:array, [:lasgn, :a], [:lasgn, :b]],
1667
+ [:lasgn, :c],
1668
+ [:to_ary,
1669
+ [:call, [:vcall, :d], :e,
1670
+ [:array, [:str, 'f']]]]])
1671
+
1672
+ add_tests("match",
1673
+ "RawParseTree" => [:if, [:match, [:lit, /x/]], [:lit, 1], nil])
1674
+
1675
+ add_tests("match2",
1676
+ "RawParseTree" => [:match2, [:lit, /x/], [:str, "blah"]])
1677
+
1678
+ add_tests("match3",
1679
+ "RawParseTree" => [:match3, [:lit, /x/], [:str, "blah"]])
1680
+
1681
+ add_tests("module",
1682
+ "RawParseTree" => [:module, :X,
1683
+ [:scope,
1684
+ [:defn, :y,
1685
+ [:scope, [:block, [:args], [:nil]]]]]])
1686
+
1687
+ add_tests("module_scoped",
1688
+ "RawParseTree" => [:module, [:colon2, [:const, :X], :Y],
1689
+ [:scope, [:vcall, :c]]])
1690
+
1691
+ add_tests("module_scoped3",
1692
+ "RawParseTree" => [:module, [:colon3, :Y], [:scope, [:vcall, :c]]])
1693
+
1694
+ add_tests("next",
1695
+ "RawParseTree" => [:iter,
1696
+ [:fcall, :loop],
1697
+ nil,
1698
+ [:if, [:false], [:next], nil]])
1699
+
1700
+ add_tests("next_arg",
1701
+ "RawParseTree" => [:iter,
1702
+ [:fcall, :loop],
1703
+ nil,
1704
+ [:if, [:false], [:next, [:lit, 42]], nil]])
1705
+
1706
+ add_tests("not",
1707
+ "RawParseTree" => [:not, [:true]])
1708
+
1709
+ add_tests("nth_ref",
1710
+ "RawParseTree" => [:nth_ref, 1])
1711
+
1712
+ add_tests("op_asgn1",
1713
+ "RawParseTree" => [:block,
1714
+ [:lasgn, :b, [:zarray]],
1715
+ [:op_asgn1, [:lvar, :b],
1716
+ [:array, [:lit, 1]], :"||", [:lit, 10]],
1717
+ [:op_asgn1, [:lvar, :b],
1718
+ [:array, [:lit, 2]], :"&&", [:lit, 11]],
1719
+ [:op_asgn1, [:lvar, :b],
1720
+ [:array, [:lit, 3]], :+, [:lit, 12]]])
1721
+
1722
+ add_tests("op_asgn1_ivar",
1723
+ "RawParseTree" => [:block,
1724
+ [:iasgn, :@b, [:zarray]],
1725
+ [:op_asgn1, [:ivar, :@b],
1726
+ [:array, [:lit, 1]], :"||", [:lit, 10]],
1727
+ [:op_asgn1, [:ivar, :@b],
1728
+ [:array, [:lit, 2]], :"&&", [:lit, 11]],
1729
+ [:op_asgn1, [:ivar, :@b],
1730
+ [:array, [:lit, 3]], :+, [:lit, 12]]])
1731
+
1732
+ add_tests("op_asgn2",
1733
+ "RawParseTree" => [:block,
1734
+ [:lasgn, :s,
1735
+ [:call, [:const, :Struct],
1736
+ :new, [:array, [:lit, :var]]]],
1737
+ [:lasgn, :c,
1738
+ [:call, [:lvar, :s], :new, [:array, [:nil]]]],
1739
+
1740
+ [:op_asgn2, [:lvar, :c], :var=, :"||",
1741
+ [:lit, 20]],
1742
+ [:op_asgn2, [:lvar, :c], :var=, :"&&",
1743
+ [:lit, 21]],
1744
+ [:op_asgn2, [:lvar, :c], :var=, :+, [:lit, 22]],
1745
+
1746
+ [:op_asgn2,
1747
+ [:call,
1748
+ [:call, [:lvar, :c], :d], :e], :f=, :"||",
1749
+ [:lit, 42]]])
1750
+
1751
+ add_tests("op_asgn2_self",
1752
+ "RawParseTree" => [:op_asgn2, [:self], :"Bag=", :"||",
1753
+ [:call, [:const, :Bag], :new]])
1754
+
1755
+ add_tests("op_asgn_and",
1756
+ "RawParseTree" => [:block,
1757
+ [:lasgn, :a, [:lit, 0]],
1758
+ [:op_asgn_and,
1759
+ [:lvar, :a], [:lasgn, :a, [:lit, 2]]]])
1760
+
1761
+ add_tests("op_asgn_and_ivar2",
1762
+ "RawParseTree" => [:op_asgn_and,
1763
+ [:ivar, :@fetcher],
1764
+ [:iasgn,
1765
+ :@fetcher,
1766
+ [:fcall,
1767
+ :new,
1768
+ [:array,
1769
+ [:call,
1770
+ [:call, [:const, :Gem], :configuration],
1771
+ :[],
1772
+ [:array, [:lit, :http_proxy]]]]]]])
1773
+
1774
+ add_tests("op_asgn_or",
1775
+ "RawParseTree" => [:block,
1776
+ [:lasgn, :a, [:lit, 0]],
1777
+ [:op_asgn_or,
1778
+ [:lvar, :a], [:lasgn, :a, [:lit, 1]]]])
1779
+
1780
+ add_tests("op_asgn_or_block",
1781
+ "RawParseTree" => [:op_asgn_or,
1782
+ [:lvar, :a],
1783
+ [:lasgn, :a,
1784
+ [:rescue,
1785
+ [:vcall, :b],
1786
+ [:resbody, nil, [:vcall, :c]]]]])
1787
+
1788
+ add_tests("op_asgn_or_ivar",
1789
+ "RawParseTree" => [:op_asgn_or,
1790
+ [:ivar, :@v],
1791
+ [:iasgn, :@v, [:hash]]])
1792
+
1793
+ add_tests("op_asgn_or_ivar2",
1794
+ "RawParseTree" => [:op_asgn_or,
1795
+ [:ivar, :@fetcher],
1796
+ [:iasgn,
1797
+ :@fetcher,
1798
+ [:fcall,
1799
+ :new,
1800
+ [:array,
1801
+ [:call,
1802
+ [:call, [:const, :Gem], :configuration],
1803
+ :[],
1804
+ [:array, [:lit, :http_proxy]]]]]]])
1805
+
1806
+ add_tests("or",
1807
+ "RawParseTree" => [:or, [:vcall, :a], [:vcall, :b]])
1808
+
1809
+ add_tests("or_big",
1810
+ "RawParseTree" => [:or,
1811
+ [:or, [:vcall, :a], [:vcall, :b]],
1812
+ [:and, [:vcall, :c], [:vcall, :d]]])
1813
+
1814
+ add_tests("or_big2",
1815
+ "RawParseTree" => [:or,
1816
+ [:or, [:vcall, :a], [:vcall, :b]],
1817
+ [:and, [:vcall, :c], [:vcall, :d]]])
1818
+
1819
+ add_tests("parse_floats_as_args",
1820
+ "RawParseTree" => [:defn, :x,
1821
+ [:scope,
1822
+ [:block,
1823
+ [:args, :a, :b,
1824
+ [:block,
1825
+ [:lasgn, :a, [:lit, 0.0]],
1826
+ [:lasgn, :b, [:lit, 0.0]]]],
1827
+ [:call, [:lvar, :a], :+,
1828
+ [:array, [:lvar, :b]]]]]])
1829
+
1830
+ add_tests("postexe",
1831
+ "RawParseTree" => [:iter, [:postexe], nil, [:lit, 1]])
1832
+
1833
+ add_tests("proc_args_0",
1834
+ "RawParseTree" => [:iter,
1835
+ [:fcall, :proc],
1836
+ 0,
1837
+ [:call, [:vcall, :x], :+, [:array, [:lit, 1]]]])
1838
+
1839
+ add_tests("proc_args_1",
1840
+ "RawParseTree" => [:iter,
1841
+ [:fcall, :proc],
1842
+ [:dasgn_curr, :x],
1843
+ [:call, [:dvar, :x], :+, [:array, [:lit, 1]]]])
1844
+
1845
+ add_tests("proc_args_2",
1846
+ "RawParseTree" => [:iter,
1847
+ [:fcall, :proc],
1848
+ [:masgn, [:array,
1849
+ [:dasgn_curr, :x],
1850
+ [:dasgn_curr, :y]], nil, nil],
1851
+ [:call, [:dvar, :x], :+, [:array, [:dvar, :y]]]])
1852
+
1853
+ add_tests("proc_args_no",
1854
+ "RawParseTree" => [:iter,
1855
+ [:fcall, :proc],
1856
+ nil,
1857
+ [:call, [:vcall, :x], :+, [:array, [:lit, 1]]]])
1858
+
1859
+ add_tests("redo",
1860
+ "RawParseTree" => [:iter,
1861
+ [:fcall, :loop], nil,
1862
+ [:if, [:false], [:redo], nil]])
1863
+
1864
+ # TODO: need a resbody w/ multiple classes and a splat
1865
+
1866
+ add_tests("rescue",
1867
+ "RawParseTree" => [:rescue,
1868
+ [:vcall, :blah], [:resbody, nil, [:nil]]])
1869
+
1870
+ add_tests("rescue_block_body",
1871
+ "RawParseTree" => [:rescue,
1872
+ [:vcall, :a],
1873
+ [:resbody, nil,
1874
+ [:block,
1875
+ [:lasgn, :e, [:gvar, :$!]],
1876
+ [:vcall, :c],
1877
+ [:vcall, :d]]]])
1878
+
1879
+ add_tests("rescue_block_body_3",
1880
+ "RawParseTree" => [:rescue,
1881
+ [:vcall, :a],
1882
+ [:resbody, [:array, [:const, :A]],
1883
+ [:vcall, :b],
1884
+ [:resbody, [:array, [:const, :B]],
1885
+ [:vcall, :c],
1886
+ [:resbody, [:array, [:const, :C]],
1887
+ [:vcall, :d]]]]])
1888
+
1889
+ add_tests("rescue_block_body_ivar",
1890
+ "RawParseTree" => [:rescue,
1891
+ [:vcall, :a],
1892
+ [:resbody, nil,
1893
+ [:block,
1894
+ [:iasgn, :@e, [:gvar, :$!]],
1895
+ [:vcall, :c],
1896
+ [:vcall, :d]]]])
1897
+
1898
+ add_tests("rescue_block_nada",
1899
+ "RawParseTree" => [:rescue, [:vcall, :blah], [:resbody, nil]])
1900
+
1901
+ add_tests("rescue_exceptions",
1902
+ "RawParseTree" => [:rescue,
1903
+ [:vcall, :blah],
1904
+ [:resbody,
1905
+ [:array, [:const, :RuntimeError]],
1906
+ [:lasgn, :r, [:gvar, :$!]]]])
1907
+
1908
+
1909
+ add_tests("rescue_iasgn_var_empty",
1910
+ "RawParseTree" => [:rescue,
1911
+ [:lit, 1],
1912
+ [:resbody, nil, [:iasgn, :@e, [:gvar, :$!]]]])
1913
+
1914
+ add_tests("rescue_lasgn",
1915
+ "RawParseTree" => [:rescue,
1916
+ [:lit, 1],
1917
+ [:resbody, nil, [:lasgn, :var, [:lit, 2]]]])
1918
+
1919
+ add_tests("rescue_lasgn_var",
1920
+ "RawParseTree" => [:rescue,
1921
+ [:lit, 1],
1922
+ [:resbody, nil,
1923
+ [:block,
1924
+ [:lasgn, :e, [:gvar, :$!]],
1925
+ [:lasgn, :var, [:lit, 2]]]]])
1926
+
1927
+ add_tests("rescue_lasgn_var_empty",
1928
+ "RawParseTree" => [:rescue,
1929
+ [:lit, 1],
1930
+ [:resbody, nil, [:lasgn, :e, [:gvar, :$!]]]])
1931
+
1932
+ add_tests("retry",
1933
+ "RawParseTree" => [:retry])
1934
+
1935
+ add_tests("return_0",
1936
+ "RawParseTree" => [:return])
1937
+
1938
+ add_tests("return_1",
1939
+ "RawParseTree" => [:return, [:lit, 1]])
1940
+
1941
+ add_tests("return_1_splatted",
1942
+ "RawParseTree" => [:return, [:svalue, [:splat, [:lit, 1]]]])
1943
+
1944
+ add_tests("return_n",
1945
+ "RawParseTree" => [:return, [:array,
1946
+ [:lit, 1], [:lit, 2], [:lit, 3]]])
1947
+
1948
+ add_tests("sclass",
1949
+ "RawParseTree" => [:sclass, [:self], [:scope, [:lit, 42]]])
1950
+
1951
+ add_tests("sclass_trailing_class",
1952
+ "RawParseTree" => [:class, :A, nil,
1953
+ [:scope,
1954
+ [:block,
1955
+ [:sclass, [:self], [:scope, [:vcall, :a]]],
1956
+ [:class, :B, nil, [:scope]]]]])
1957
+
1958
+ add_tests("splat",
1959
+ "RawParseTree" => [:defn, :x,
1960
+ [:scope,
1961
+ [:block,
1962
+ [:args, :"*b"],
1963
+ [:fcall, :a, [:splat, [:lvar, :b]]]]]])
1964
+
1965
+ add_tests("splat_array",
1966
+ "RawParseTree" => [:splat, [:array, [:lit, 1]]])
1967
+
1968
+ add_tests("splat_break",
1969
+ "RawParseTree" => [:break, [:svalue, [:splat, [:array, [:lit, 1]]]]])
1970
+
1971
+ add_tests("splat_break_array",
1972
+ "RawParseTree" => [:break, [:splat, [:array, [:lit, 1]]]])
1973
+
1974
+ add_tests("splat_fcall",
1975
+ "RawParseTree" => [:fcall, :meth,
1976
+ [:splat, [:array, [:lit, 1]]]])
1977
+
1978
+ add_tests("splat_fcall_array",
1979
+ "RawParseTree" => [:fcall, :meth,
1980
+ [:array, [:splat, [:array, [:lit, 1]]]]])
1981
+
1982
+ add_tests("splat_lasgn",
1983
+ "RawParseTree" => [:lasgn, :x, [:svalue, [:splat, [:array, [:lit, 1]]]]])
1984
+
1985
+ add_tests("splat_lasgn_array",
1986
+ "RawParseTree" => [:lasgn, :x, [:splat, [:array, [:lit, 1]]]])
1987
+
1988
+ add_tests("splat_lit_1",
1989
+ "RawParseTree" => [:splat, [:lit, 1]]) # UGH - damn MRI
1990
+
1991
+ add_tests("splat_lit_n",
1992
+ "RawParseTree" => [:argscat, [:array, [:lit, 1]], [:lit, 2]])
1993
+
1994
+ add_tests("splat_next",
1995
+ "RawParseTree" => [:next, [:svalue, [:splat, [:array, [:lit, 1]]]]])
1996
+
1997
+ add_tests("splat_next_array",
1998
+ "RawParseTree" => [:next, [:splat, [:array, [:lit, 1]]]])
1999
+
2000
+ add_tests("splat_return",
2001
+ "RawParseTree" => [:return, [:svalue, [:splat, [:array, [:lit, 1]]]]])
2002
+
2003
+ add_tests("splat_return_array",
2004
+ "RawParseTree" => [:return, [:splat, [:array, [:lit, 1]]]])
2005
+
2006
+ add_tests("splat_super",
2007
+ "RawParseTree" => [:super, [:splat, [:array, [:lit, 1]]]])
2008
+
2009
+ add_tests("splat_super_array",
2010
+ "RawParseTree" => [:super, [:array, [:splat, [:array, [:lit, 1]]]]])
2011
+
2012
+ add_tests("splat_yield",
2013
+ "RawParseTree" => [:yield, [:splat, [:array, [:lit, 1]]]])
2014
+
2015
+ add_tests("splat_yield_array",
2016
+ "RawParseTree" => [:yield, [:splat, [:array, [:lit, 1]]], true])
2017
+
2018
+ add_tests("str",
2019
+ "RawParseTree" => [:str, "x"])
2020
+
2021
+ add_tests("str_concat_newline",
2022
+ "RawParseTree" => [:str, "before after"])
2023
+
2024
+ add_tests("str_concat_space",
2025
+ "RawParseTree" => [:str, "before after"])
2026
+
2027
+ add_tests("str_heredoc",
2028
+ "RawParseTree" => [:str, " blah\nblah\n"])
2029
+
2030
+ add_tests("str_heredoc_call",
2031
+ "RawParseTree" => [:call, [:str, " blah\nblah\n"], :strip])
2032
+
2033
+ add_tests("str_heredoc_double",
2034
+ "RawParseTree" => [:lasgn, :a,
2035
+ [:call,
2036
+ [:lvar, :a],
2037
+ :+,
2038
+ [:array,
2039
+ [:call,
2040
+ [:call, [:str, " first\n"], :+,
2041
+ [:array, [:vcall, :b]]],
2042
+ :+,
2043
+ [:array, [:str, " second\n"]]]]]])
2044
+
2045
+ add_tests("str_heredoc_empty", # yes... tarded
2046
+ "RawParseTree" => [:str, ""])
2047
+
2048
+ add_tests("str_heredoc_indent",
2049
+ "RawParseTree" => [:str, " blah\nblah\n\n"])
2050
+
2051
+ add_tests("str_interp_file",
2052
+ "RawParseTree" => [:str, "file = (string)\n"])
2053
+
2054
+ add_tests("structure_extra_block_for_dvar_scoping",
2055
+ "RawParseTree" => [:iter,
2056
+ [:call, [:vcall, :a], :b],
2057
+ [:masgn, [:array,
2058
+ [:dasgn_curr, :c],
2059
+ [:dasgn_curr, :d]], nil, nil],
2060
+ [:if,
2061
+ [:call, [:vcall, :e], :f,
2062
+ [:array, [:dvar, :c]]],
2063
+ nil,
2064
+ [:block,
2065
+ [:dasgn_curr, :g, [:false]],
2066
+ [:iter,
2067
+ [:call, [:dvar, :d], :h],
2068
+ [:masgn, [:array,
2069
+ [:dasgn_curr, :x],
2070
+ [:dasgn_curr, :i]], nil, nil],
2071
+ [:dasgn, :g, [:true]]]]]])
2072
+
2073
+ add_tests("structure_remove_begin_1",
2074
+ "RawParseTree" => [:call, [:vcall, :a], :<<,
2075
+ [:array, [:rescue, [:vcall, :b],
2076
+ [:resbody, nil, [:vcall, :c]]]]])
2077
+
2078
+ add_tests("structure_remove_begin_2",
2079
+ "RawParseTree" => [:block,
2080
+ [:lasgn,
2081
+ :a,
2082
+ [:if, [:vcall, :c],
2083
+ [:rescue,
2084
+ [:vcall, :b],
2085
+ [:resbody, nil, [:nil]]],
2086
+ nil]],
2087
+ [:lvar, :a]])
2088
+
2089
+ add_tests("structure_unused_literal_wwtt",
2090
+ "RawParseTree" => [:module, :Graffle, [:scope]])
2091
+
2092
+ add_tests("super_0",
2093
+ "RawParseTree" => [:defn, :x,
2094
+ [:scope,
2095
+ [:block, [:args], [:super]]]])
2096
+
2097
+ add_tests("super_1",
2098
+ "RawParseTree" => [:defn, :x,
2099
+ [:scope,
2100
+ [:block,
2101
+ [:args],
2102
+ [:super, [:array, [:lit, 4]]]]]])
2103
+
2104
+ add_tests("super_1_array",
2105
+ "RawParseTree" => [:defn, :x,
2106
+ [:scope,
2107
+ [:block,
2108
+ [:args],
2109
+ [:super,
2110
+ [:array,
2111
+ [:array, [:lit, 24], [:lit, 42]]]]]]])
2112
+
2113
+ add_tests("super_block_pass",
2114
+ "RawParseTree" => [:block_pass,
2115
+ [:vcall, :b], [:super, [:array, [:vcall, :a]]]])
2116
+
2117
+ add_tests("super_block_splat",
2118
+ "RawParseTree" => [:super,
2119
+ [:argscat,
2120
+ [:array, [:vcall, :a]],
2121
+ [:vcall, :b]]])
2122
+
2123
+ add_tests("super_n",
2124
+ "RawParseTree" => [:defn, :x,
2125
+ [:scope,
2126
+ [:block,
2127
+ [:args],
2128
+ [:super, [:array, [:lit, 24], [:lit, 42]]]]]])
2129
+
2130
+ add_tests("svalue",
2131
+ "RawParseTree" => [:lasgn, :a, [:svalue, [:splat, [:vcall, :b]]]])
2132
+
2133
+ add_tests("to_ary",
2134
+ "RawParseTree" => [:masgn,
2135
+ [:array, [:lasgn, :a], [:lasgn, :b]], nil,
2136
+ [:to_ary, [:vcall, :c]]])
2137
+
2138
+ add_tests("true",
2139
+ "RawParseTree" => [:true])
2140
+
2141
+ add_tests("undef",
2142
+ "RawParseTree" => [:undef, [:lit, :x]])
2143
+
2144
+ add_tests("undef_2",
2145
+ "RawParseTree" => [:block,
2146
+ [:undef, [:lit, :x]],
2147
+ [:undef, [:lit, :y]]])
2148
+
2149
+ add_tests("undef_3",
2150
+ "RawParseTree" => [:block,
2151
+ [:undef, [:lit, :x]],
2152
+ [:undef, [:lit, :y]],
2153
+ [:undef, [:lit, :z]]])
2154
+
2155
+ add_tests("undef_block_1",
2156
+ "RawParseTree" => [:block,
2157
+ [:vcall, :f1],
2158
+ [:undef, [:lit, :x]]])
2159
+
2160
+ add_tests("undef_block_2",
2161
+ "RawParseTree" => [:block,
2162
+ [:vcall, :f1],
2163
+ [:block,
2164
+ [:undef, [:lit, :x]],
2165
+ [:undef, [:lit, :y]],
2166
+ ]])
2167
+
2168
+ add_tests("undef_block_3",
2169
+ "RawParseTree" => [:block,
2170
+ [:vcall, :f1],
2171
+ [:block,
2172
+ [:undef, [:lit, :x]],
2173
+ [:undef, [:lit, :y]],
2174
+ [:undef, [:lit, :z]],
2175
+ ]])
2176
+
2177
+ add_tests("undef_block_3_post",
2178
+ "RawParseTree" => [:block,
2179
+ [:undef, [:lit, :x]],
2180
+ [:undef, [:lit, :y]],
2181
+ [:undef, [:lit, :z]],
2182
+ [:vcall, :f2]])
2183
+
2184
+ add_tests("undef_block_wtf",
2185
+ "RawParseTree" => [:block,
2186
+ [:vcall, :f1],
2187
+ [:block,
2188
+ [:undef, [:lit, :x]],
2189
+ [:undef, [:lit, :y]],
2190
+ [:undef, [:lit, :z]]],
2191
+ [:vcall, :f2]])
2192
+
2193
+
2194
+ add_tests("unless_post",
2195
+ "RawParseTree" => [:if, [:vcall, :b], nil, [:vcall, :a]])
2196
+
2197
+ add_tests("unless_post_not",
2198
+ "RawParseTree" => [:if, [:vcall, :b], [:vcall, :a], nil])
2199
+
2200
+ add_tests("unless_pre",
2201
+ "RawParseTree" => [:if, [:vcall, :b], nil, [:vcall, :a]])
2202
+
2203
+ add_tests("unless_pre_not",
2204
+ "RawParseTree" => [:if, [:vcall, :b], [:vcall, :a], nil])
2205
+
2206
+ add_tests("until_post",
2207
+ "RawParseTree" => [:until, [:false],
2208
+ [:call, [:lit, 1], :+,
2209
+ [:array, [:lit, 1]]], false])
2210
+
2211
+ add_tests("until_post_not",
2212
+ "RawParseTree" => [:while, [:true],
2213
+ [:call, [:lit, 1], :+,
2214
+ [:array, [:lit, 1]]], false])
2215
+
2216
+ add_tests("until_pre",
2217
+ "RawParseTree" => [:until, [:false],
2218
+ [:call, [:lit, 1], :+,
2219
+ [:array, [:lit, 1]]], true])
2220
+
2221
+ add_tests("until_pre_mod",
2222
+ "RawParseTree" => [:until, [:false],
2223
+ [:call, [:lit, 1], :+,
2224
+ [:array, [:lit, 1]]], true])
2225
+
2226
+ add_tests("until_pre_not",
2227
+ "RawParseTree" => [:while, [:true],
2228
+ [:call, [:lit, 1], :+,
2229
+ [:array, [:lit, 1]]], true])
2230
+
2231
+ add_tests("until_pre_not_mod",
2232
+ "RawParseTree" => [:while, [:true],
2233
+ [:call, [:lit, 1], :+,
2234
+ [:array, [:lit, 1]]], true])
2235
+
2236
+ add_tests("valias",
2237
+ "RawParseTree" => [:valias, :$y, :$x])
2238
+
2239
+ add_tests("vcall",
2240
+ "RawParseTree" => [:vcall, :method])
2241
+
2242
+ add_tests("while_post",
2243
+ "RawParseTree" => [:while, [:false],
2244
+ [:call, [:lit, 1], :+,
2245
+ [:array, [:lit, 1]]], false])
2246
+
2247
+ add_tests("while_post2",
2248
+ "RawParseTree" => [:while, [:false],
2249
+ [:block,
2250
+ [:call, [:lit, 1], :+, [:array, [:lit, 2]]],
2251
+ [:call, [:lit, 3], :+, [:array, [:lit, 4]]]],
2252
+ false])
2253
+
2254
+ add_tests("while_post_not",
2255
+ "RawParseTree" => [:until, [:true],
2256
+ [:call, [:lit, 1], :+,
2257
+ [:array, [:lit, 1]]], false])
2258
+
2259
+ add_tests("while_pre",
2260
+ "RawParseTree" => [:while, [:false],
2261
+ [:call, [:lit, 1], :+,
2262
+ [:array, [:lit, 1]]], true])
2263
+
2264
+ add_tests("while_pre_mod",
2265
+ "RawParseTree" => [:while, [:false],
2266
+ [:call, [:lit, 1], :+,
2267
+ [:array, [:lit, 1]]], true]) # FIX can be one liner
2268
+
2269
+ add_tests("while_pre_nil",
2270
+ "RawParseTree" => [:while, [:false], nil, true])
2271
+
2272
+ add_tests("while_pre_not",
2273
+ "RawParseTree" => [:until, [:true],
2274
+ [:call, [:lit, 1], :+,
2275
+ [:array, [:lit, 1]]], true])
2276
+
2277
+ add_tests("while_pre_not_mod",
2278
+ "RawParseTree" => [:until, [:true],
2279
+ [:call, [:lit, 1], :+,
2280
+ [:array, [:lit, 1]]], true]) # FIX
2281
+
2282
+ add_tests("xstr",
2283
+ "RawParseTree" => [:xstr, 'touch 5'])
2284
+
2285
+ add_tests("yield_0",
2286
+ "RawParseTree" => [:yield])
2287
+
2288
+ add_tests("yield_1",
2289
+ "RawParseTree" => [:yield, [:lit, 42]])
2290
+
2291
+ add_tests("yield_array_0",
2292
+ "RawParseTree" => [:yield, [:zarray], true])
2293
+
2294
+ add_tests("yield_array_1",
2295
+ "RawParseTree" => [:yield, [:array, [:lit, 42]], true])
2296
+
2297
+ add_tests("yield_array_n",
2298
+ "RawParseTree" => [:yield, [:array, [:lit, 42], [:lit, 24]], true])
2299
+
2300
+ add_tests("yield_n",
2301
+ "RawParseTree" => [:yield, [:array, [:lit, 42], [:lit, 24]]])
2302
+
2303
+ add_tests("zarray",
2304
+ "RawParseTree" => [:lasgn, :a, [:zarray]])
2305
+
2306
+ add_tests("zsuper",
2307
+ "RawParseTree" => [:defn, :x,
2308
+ [:scope, [:block, [:args], [:zsuper]]]])
2309
+
2310
+ add_18tests("iter_args_ivar",
2311
+ "RawParseTree" => [:iter,
2312
+ [:fcall, :a],
2313
+ [:iasgn, :@a],
2314
+ [:lit, 42]])
2315
+
2316
+ add_18tests("iter_masgn_args_ivar",
2317
+ "RawParseTree" => [:iter,
2318
+ [:fcall, :a],
2319
+ [:masgn,
2320
+ [:array, [:dasgn_curr, :a], [:iasgn, :@b]],
2321
+ nil, nil],
2322
+ [:lit, 42]])
2323
+
2324
+ add_18tests("str_question_control",
2325
+ "RawParseTree" => [:lit, 129])
2326
+
2327
+ add_18tests("str_question_escape",
2328
+ "RawParseTree" => [:lit, 10])
2329
+
2330
+ add_18tests("str_question_literal",
2331
+ "RawParseTree" => [:lit, 97])
2332
+ end
2333
+
51
2334
  class TestRawParseTree < ParseTreeTestCase
52
2335
  def setup
53
2336
  super