sexp_processor 3.2.0 → 4.0.0
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.
- data.tar.gz.sig +0 -0
- data/History.txt +14 -0
- data/README.txt +1 -2
- data/lib/pt_testcase.rb +561 -808
- data/lib/sexp.rb +23 -1
- data/lib/sexp_processor.rb +1 -1
- metadata +9 -9
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
=== 4.0.0 / 2012-06-07
|
2
|
+
|
3
|
+
* 5 major enhancements:
|
4
|
+
|
5
|
+
* Removed :arglist from everything except :op_asgn1.
|
6
|
+
* Removed block from resbody
|
7
|
+
* Removed block from when node
|
8
|
+
* Removed block nodes inside of scope nodes (defn/defs/class/sclass).
|
9
|
+
* Removed scope nodes in defn/defs/class/sclass nodes.
|
10
|
+
|
11
|
+
* 1 minor enhancement:
|
12
|
+
|
13
|
+
* Added Sexp#deep_each and Sexp#each_sexp. Refactored from Flay
|
14
|
+
|
1
15
|
=== 3.2.0 / 2012-04-15
|
2
16
|
|
3
17
|
* 5 minor enhancements:
|
data/README.txt
CHANGED
data/lib/pt_testcase.rb
CHANGED
@@ -219,46 +219,45 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
219
219
|
add_tests("alias",
|
220
220
|
"Ruby" => "class X\n alias :y :x\nend",
|
221
221
|
"ParseTree" => s(:class, :X, nil,
|
222
|
-
s(:
|
222
|
+
s(:alias, s(:lit, :y), s(:lit, :x))))
|
223
223
|
|
224
224
|
add_tests("alias_ugh",
|
225
225
|
"Ruby" => "class X\n alias y x\nend",
|
226
226
|
"ParseTree" => s(:class, :X, nil,
|
227
|
-
s(:
|
227
|
+
s(:alias, s(:lit, :y), s(:lit, :x))),
|
228
228
|
"Ruby2Ruby" => "class X\n alias :y :x\nend")
|
229
229
|
|
230
230
|
add_tests("and",
|
231
231
|
"Ruby" => "a and b",
|
232
232
|
"ParseTree" => s(:and,
|
233
|
-
s(:call, nil, :a
|
234
|
-
s(:call, nil, :b
|
233
|
+
s(:call, nil, :a),
|
234
|
+
s(:call, nil, :b)))
|
235
235
|
|
236
236
|
add_tests("argscat_inside",
|
237
237
|
"Ruby" => "a = [b, *c]",
|
238
238
|
"ParseTree" => s(:lasgn, :a,
|
239
239
|
s(:array,
|
240
|
-
s(:call, nil, :b
|
241
|
-
s(:splat, s(:call, nil, :c
|
240
|
+
s(:call, nil, :b),
|
241
|
+
s(:splat, s(:call, nil, :c)))))
|
242
242
|
|
243
243
|
add_tests("argscat_svalue",
|
244
244
|
"Ruby" => "a = b, c, *d",
|
245
245
|
"ParseTree" => s(:lasgn, :a,
|
246
246
|
s(:svalue,
|
247
247
|
s(:array,
|
248
|
-
s(:call, nil, :b
|
249
|
-
s(:call, nil, :c
|
248
|
+
s(:call, nil, :b),
|
249
|
+
s(:call, nil, :c),
|
250
250
|
s(:splat,
|
251
|
-
s(:call, nil, :d
|
251
|
+
s(:call, nil, :d))))))
|
252
252
|
|
253
253
|
add_tests("argspush",
|
254
254
|
"Ruby" => "a[*b] = c",
|
255
255
|
"ParseTree" => s(:attrasgn,
|
256
|
-
s(:call, nil, :a
|
256
|
+
s(:call, nil, :a),
|
257
257
|
:[]=,
|
258
|
-
s(:
|
259
|
-
s(:
|
260
|
-
|
261
|
-
s(:call, nil, :c, s(:arglist)))))
|
258
|
+
s(:splat,
|
259
|
+
s(:call, nil, :b)),
|
260
|
+
s(:call, nil, :c)))
|
262
261
|
|
263
262
|
add_tests("array",
|
264
263
|
"Ruby" => "[1, :b, \"c\"]",
|
@@ -296,22 +295,22 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
296
295
|
"Ruby" => "y = 0\n42.method = y\n",
|
297
296
|
"ParseTree" => s(:block,
|
298
297
|
s(:lasgn, :y, s(:lit, 0)),
|
299
|
-
s(:attrasgn,
|
300
|
-
s(:
|
298
|
+
s(:attrasgn,
|
299
|
+
s(:lit, 42), :method=, s(:lvar, :y))))
|
301
300
|
|
302
301
|
add_tests("attrasgn_index_equals",
|
303
302
|
"Ruby" => "a[42] = 24",
|
304
303
|
"ParseTree" => s(:attrasgn,
|
305
|
-
s(:call, nil, :a
|
304
|
+
s(:call, nil, :a),
|
306
305
|
:[]=,
|
307
|
-
s(:
|
306
|
+
s(:lit, 42), s(:lit, 24)))
|
308
307
|
|
309
308
|
add_tests("attrasgn_index_equals_space",
|
310
309
|
"Ruby" => "a = []; a [42] = 24",
|
311
310
|
"ParseTree" => s(:block,
|
312
311
|
s(:lasgn, :a, s(:array)),
|
313
312
|
s(:attrasgn, s(:lvar, :a), :[]=,
|
314
|
-
s(:
|
313
|
+
s(:lit, 42), s(:lit, 24))),
|
315
314
|
"Ruby2Ruby" => "a = []\na[42] = 24\n")
|
316
315
|
|
317
316
|
add_tests("attrset",
|
@@ -331,21 +330,19 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
331
330
|
|
332
331
|
add_tests("begin",
|
333
332
|
"Ruby" => "begin\n (1 + 1)\nend",
|
334
|
-
"ParseTree" => s(:call, s(:lit, 1), :+,
|
335
|
-
s(:arglist, s(:lit, 1))),
|
333
|
+
"ParseTree" => s(:call, s(:lit, 1), :+, s(:lit, 1)),
|
336
334
|
"Ruby2Ruby" => "(1 + 1)")
|
337
335
|
|
338
336
|
add_tests("begin_def",
|
339
337
|
"Ruby" => "def m\n begin\n\n end\nend",
|
340
|
-
"ParseTree" => s(:defn, :m, s(:args),
|
341
|
-
s(:scope, s(:block, s(:nil)))),
|
338
|
+
"ParseTree" => s(:defn, :m, s(:args), s(:nil)),
|
342
339
|
"Ruby2Ruby" => "def m\n # do nothing\nend")
|
343
340
|
|
344
341
|
add_tests("begin_rescue_ensure",
|
345
342
|
"Ruby" => "begin\n a\nrescue\n # do nothing\nensure\n # do nothing\nend",
|
346
343
|
"ParseTree" => s(:ensure,
|
347
344
|
s(:rescue,
|
348
|
-
s(:call, nil, :a
|
345
|
+
s(:call, nil, :a),
|
349
346
|
s(:resbody, s(:array), nil)),
|
350
347
|
s(:nil)))
|
351
348
|
|
@@ -360,12 +357,12 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
360
357
|
"Ruby" => "begin\n a\nrescue => mes\n # do nothing\nend\nbegin\n b\nrescue => mes\n # do nothing\nend\n",
|
361
358
|
"ParseTree" => s(:block,
|
362
359
|
s(:rescue,
|
363
|
-
s(:call, nil, :a
|
360
|
+
s(:call, nil, :a),
|
364
361
|
s(:resbody,
|
365
362
|
s(:array, s(:lasgn, :mes, s(:gvar, :$!))),
|
366
363
|
nil)),
|
367
364
|
s(:rescue,
|
368
|
-
s(:call, nil, :b
|
365
|
+
s(:call, nil, :b),
|
369
366
|
s(:resbody,
|
370
367
|
s(:array,
|
371
368
|
s(:lasgn, :mes, s(:gvar, :$!))),
|
@@ -378,13 +375,10 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
378
375
|
"Ruby" => "def self.setup(ctx)\n bind = allocate\n bind.context = ctx\n return bind\nend",
|
379
376
|
"ParseTree" => s(:defs, s(:self), :setup,
|
380
377
|
s(:args, :ctx),
|
381
|
-
s(:
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
s(:attrasgn, s(:lvar, :bind), :context=,
|
386
|
-
s(:arglist, s(:lvar, :ctx))),
|
387
|
-
s(:return, s(:lvar, :bind))))))
|
378
|
+
s(:lasgn, :bind, s(:call, nil, :allocate)),
|
379
|
+
s(:attrasgn,
|
380
|
+
s(:lvar, :bind), :context=, s(:lvar, :ctx)),
|
381
|
+
s(:return, s(:lvar, :bind))))
|
388
382
|
|
389
383
|
|
390
384
|
add_tests("block_lasgn",
|
@@ -392,137 +386,109 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
392
386
|
"ParseTree" => s(:lasgn, :x,
|
393
387
|
s(:block,
|
394
388
|
s(:lasgn, :y, s(:lit, 1)),
|
395
|
-
s(:call, s(:lvar, :y), :+,
|
396
|
-
s(:arglist, s(:lit, 2))))))
|
389
|
+
s(:call, s(:lvar, :y), :+, s(:lit, 2)))))
|
397
390
|
|
398
391
|
add_tests("block_mystery_block",
|
399
392
|
"Ruby" => "a(b) do\n if b then\n true\n else\n c = false\n d { |x| c = true }\n c\n end\nend",
|
400
393
|
"ParseTree" => s(:iter,
|
401
|
-
s(:call, nil, :a,
|
402
|
-
s(:arglist, s(:call, nil, :b, s(:arglist)))),
|
394
|
+
s(:call, nil, :a, s(:call, nil, :b)),
|
403
395
|
nil,
|
404
396
|
s(:if,
|
405
|
-
s(:call, nil, :b
|
397
|
+
s(:call, nil, :b),
|
406
398
|
s(:true),
|
407
399
|
s(:block,
|
408
400
|
s(:lasgn, :c, s(:false)),
|
409
401
|
s(:iter,
|
410
|
-
s(:call, nil, :d
|
402
|
+
s(:call, nil, :d),
|
411
403
|
s(:lasgn, :x),
|
412
404
|
s(:lasgn, :c, s(:true))),
|
413
405
|
s(:lvar, :c)))))
|
414
406
|
|
415
407
|
add_tests("block_pass_args_and_splat",
|
416
408
|
"Ruby" => "def blah(*args, &block)\n other(42, *args, &block)\nend",
|
417
|
-
"ParseTree" => s(:defn, :blah,
|
418
|
-
s(:
|
419
|
-
|
420
|
-
s(:
|
421
|
-
|
422
|
-
s(:arglist,
|
423
|
-
s(:lit, 42),
|
424
|
-
s(:splat, s(:lvar, :args)),
|
425
|
-
s(:block_pass, s(:lvar, :block))))))))
|
409
|
+
"ParseTree" => s(:defn, :blah, s(:args, :"*args", :"&block"),
|
410
|
+
s(:call, nil, :other,
|
411
|
+
s(:lit, 42),
|
412
|
+
s(:splat, s(:lvar, :args)),
|
413
|
+
s(:block_pass, s(:lvar, :block)))))
|
426
414
|
|
427
415
|
add_tests("block_pass_call_0",
|
428
416
|
"Ruby" => "a.b(&c)",
|
429
417
|
"ParseTree" => s(:call,
|
430
|
-
s(:call, nil, :a
|
418
|
+
s(:call, nil, :a),
|
431
419
|
:b,
|
432
|
-
s(:
|
433
|
-
s(:block_pass,
|
434
|
-
s(:call, nil, :c, s(:arglist))))))
|
420
|
+
s(:block_pass, s(:call, nil, :c))))
|
435
421
|
|
436
422
|
add_tests("block_pass_call_1",
|
437
423
|
"Ruby" => "a.b(4, &c)",
|
438
424
|
"ParseTree" => s(:call,
|
439
|
-
s(:call, nil, :a
|
425
|
+
s(:call, nil, :a),
|
440
426
|
:b,
|
441
|
-
s(:
|
442
|
-
|
443
|
-
s(:block_pass,
|
444
|
-
s(:call, nil, :c, s(:arglist))))))
|
427
|
+
s(:lit, 4),
|
428
|
+
s(:block_pass, s(:call, nil, :c))))
|
445
429
|
|
446
430
|
add_tests("block_pass_call_n",
|
447
431
|
"Ruby" => "a.b(1, 2, 3, &c)",
|
448
432
|
"ParseTree" => s(:call,
|
449
|
-
s(:call, nil, :a
|
433
|
+
s(:call, nil, :a),
|
450
434
|
:b,
|
451
|
-
s(:
|
452
|
-
|
453
|
-
s(:block_pass,
|
454
|
-
s(:call, nil, :c, s(:arglist))))))
|
435
|
+
s(:lit, 1), s(:lit, 2), s(:lit, 3),
|
436
|
+
s(:block_pass, s(:call, nil, :c))))
|
455
437
|
|
456
438
|
add_tests("block_pass_fcall_0",
|
457
439
|
"Ruby" => "a(&b)",
|
458
440
|
"ParseTree" => s(:call, nil, :a,
|
459
|
-
s(:
|
460
|
-
s(:block_pass,
|
461
|
-
s(:call, nil, :b, s(:arglist))))))
|
441
|
+
s(:block_pass, s(:call, nil, :b))))
|
462
442
|
|
463
443
|
add_tests("block_pass_fcall_1",
|
464
444
|
"Ruby" => "a(4, &b)",
|
465
445
|
"ParseTree" => s(:call, nil, :a,
|
466
|
-
s(:
|
467
|
-
|
468
|
-
s(:block_pass,
|
469
|
-
s(:call, nil, :b, s(:arglist))))))
|
446
|
+
s(:lit, 4),
|
447
|
+
s(:block_pass, s(:call, nil, :b))))
|
470
448
|
|
471
449
|
add_tests("block_pass_fcall_n",
|
472
450
|
"Ruby" => "a(1, 2, 3, &b)",
|
473
451
|
"ParseTree" => s(:call, nil, :a,
|
474
|
-
s(:
|
475
|
-
|
476
|
-
s(:block_pass,
|
477
|
-
s(:call, nil, :b, s(:arglist))))))
|
452
|
+
s(:lit, 1), s(:lit, 2), s(:lit, 3),
|
453
|
+
s(:block_pass, s(:call, nil, :b))))
|
478
454
|
|
479
455
|
add_tests("block_pass_omgwtf",
|
480
456
|
"Ruby" => "define_attr_method(:x, :sequence_name, &Proc.new { |*args| nil })",
|
481
457
|
"ParseTree" => s(:call, nil, :define_attr_method,
|
482
|
-
s(:
|
483
|
-
|
484
|
-
|
485
|
-
s(:
|
486
|
-
s(:
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
s(:array, s(:splat, s(:lasgn, :args)))),
|
491
|
-
s(:nil))))))
|
458
|
+
s(:lit, :x),
|
459
|
+
s(:lit, :sequence_name),
|
460
|
+
s(:block_pass,
|
461
|
+
s(:iter,
|
462
|
+
s(:call, s(:const, :Proc), :new),
|
463
|
+
s(:masgn,
|
464
|
+
s(:array, s(:splat, s(:lasgn, :args)))),
|
465
|
+
s(:nil)))))
|
492
466
|
|
493
467
|
add_tests("block_pass_splat",
|
494
468
|
"Ruby" => "def blah(*args, &block)\n other(*args, &block)\nend",
|
495
469
|
"ParseTree" => s(:defn, :blah,
|
496
470
|
s(:args, :"*args", :"&block"),
|
497
|
-
s(:
|
498
|
-
s(:
|
499
|
-
|
500
|
-
s(:arglist,
|
501
|
-
s(:splat, s(:lvar, :args)),
|
502
|
-
s(:block_pass, s(:lvar, :block))))))))
|
471
|
+
s(:call, nil, :other,
|
472
|
+
s(:splat, s(:lvar, :args)),
|
473
|
+
s(:block_pass, s(:lvar, :block)))))
|
503
474
|
|
504
475
|
add_tests("block_pass_thingy",
|
505
476
|
"Ruby" => "r.read_body(dest, &block)",
|
506
477
|
"ParseTree" => s(:call,
|
507
|
-
s(:call, nil, :r
|
478
|
+
s(:call, nil, :r),
|
508
479
|
:read_body,
|
509
|
-
s(:
|
510
|
-
|
511
|
-
s(:block_pass,
|
512
|
-
s(:call, nil, :block, s(:arglist))))))
|
480
|
+
s(:call, nil, :dest),
|
481
|
+
s(:block_pass, s(:call, nil, :block))))
|
513
482
|
|
514
483
|
add_tests("block_stmt_after",
|
515
484
|
"Ruby" => "def f\n begin\n b\n rescue\n c\n end\n\n d\nend",
|
516
|
-
"ParseTree" => s(:defn, :f,
|
517
|
-
s(:
|
518
|
-
|
519
|
-
s(:
|
520
|
-
s(:
|
521
|
-
|
522
|
-
|
523
|
-
s(:array),
|
524
|
-
s(:call, nil, :c, s(:arglist)))),
|
525
|
-
s(:call, nil, :d, s(:arglist))))),
|
485
|
+
"ParseTree" => s(:defn, :f, s(:args),
|
486
|
+
s(:rescue,
|
487
|
+
s(:call, nil, :b),
|
488
|
+
s(:resbody,
|
489
|
+
s(:array),
|
490
|
+
s(:call, nil, :c))),
|
491
|
+
s(:call, nil, :d)),
|
526
492
|
"Ruby2Ruby" => "def f\n b rescue c\n d\nend")
|
527
493
|
|
528
494
|
copy_test_case "block_stmt_after", "Ruby"
|
@@ -531,15 +497,12 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
531
497
|
|
532
498
|
add_tests("block_stmt_before",
|
533
499
|
"Ruby" => "def f\n a\n begin\n b\n rescue\n c\n end\nend",
|
534
|
-
"ParseTree" => s(:defn, :f,
|
535
|
-
s(:
|
536
|
-
s(:
|
537
|
-
s(:
|
538
|
-
s(:
|
539
|
-
s(:
|
540
|
-
s(:resbody,
|
541
|
-
s(:array),
|
542
|
-
s(:call, nil, :c, s(:arglist))))))),
|
500
|
+
"ParseTree" => s(:defn, :f, s(:args),
|
501
|
+
s(:call, nil, :a),
|
502
|
+
s(:rescue, s(:call, nil, :b),
|
503
|
+
s(:resbody,
|
504
|
+
s(:array),
|
505
|
+
s(:call, nil, :c)))),
|
543
506
|
"Ruby2Ruby" => "def f\n a\n b rescue c\nend")
|
544
507
|
|
545
508
|
# oddly... this one doesn't HAVE any differences when verbose... new?
|
@@ -550,15 +513,13 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
550
513
|
add_tests("block_stmt_both",
|
551
514
|
"Ruby" => "def f\n a\n begin\n b\n rescue\n c\n end\n d\nend",
|
552
515
|
"ParseTree" => s(:defn, :f, s(:args),
|
553
|
-
s(:
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
s(:call, nil, :c, s(:arglist)))),
|
561
|
-
s(:call, nil, :d, s(:arglist))))),
|
516
|
+
s(:call, nil, :a),
|
517
|
+
s(:rescue,
|
518
|
+
s(:call, nil, :b),
|
519
|
+
s(:resbody,
|
520
|
+
s(:array),
|
521
|
+
s(:call, nil, :c))),
|
522
|
+
s(:call, nil, :d)),
|
562
523
|
"Ruby2Ruby" => "def f\n a\n b rescue c\n d\nend")
|
563
524
|
|
564
525
|
copy_test_case "block_stmt_both", "Ruby"
|
@@ -567,65 +528,50 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
567
528
|
|
568
529
|
add_tests("bmethod",
|
569
530
|
"Ruby" => [Examples, :unsplatted],
|
570
|
-
"ParseTree" => s(:defn, :unsplatted,
|
571
|
-
s(:
|
572
|
-
s(:scope,
|
573
|
-
s(:block,
|
574
|
-
s(:call,
|
575
|
-
s(:lvar, :x),
|
576
|
-
:+,
|
577
|
-
s(:arglist, s(:lit, 1)))))),
|
531
|
+
"ParseTree" => s(:defn, :unsplatted, s(:args, :x),
|
532
|
+
s(:call, s(:lvar, :x), :+, s(:lit, 1))),
|
578
533
|
"Ruby2Ruby" => "def unsplatted(x)\n (x + 1)\nend")
|
579
534
|
|
580
535
|
add_tests("bmethod_noargs",
|
581
536
|
"Ruby" => [Examples, :bmethod_noargs],
|
582
|
-
"ParseTree" => s(:defn, :bmethod_noargs,
|
583
|
-
s(:
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
s(:call, nil, :x, s(:arglist)),
|
588
|
-
:"+",
|
589
|
-
s(:arglist, s(:lit, 1)))))),
|
537
|
+
"ParseTree" => s(:defn, :bmethod_noargs, s(:args),
|
538
|
+
s(:call,
|
539
|
+
s(:call, nil, :x),
|
540
|
+
:"+",
|
541
|
+
s(:lit, 1))),
|
590
542
|
"Ruby2Ruby" => "def bmethod_noargs\n (x + 1)\nend")
|
591
543
|
|
592
544
|
add_tests("bmethod_splat",
|
593
545
|
"Ruby" => [Examples, :splatted],
|
594
|
-
"ParseTree" => s(:defn, :splatted,
|
595
|
-
s(:
|
596
|
-
|
597
|
-
|
598
|
-
s(:lasgn, :y,
|
599
|
-
s(:call, s(:lvar, :args), :first,
|
600
|
-
s(:arglist))),
|
601
|
-
s(:call, s(:lvar, :y), :+,
|
602
|
-
s(:arglist, s(:lit, 42)))))),
|
546
|
+
"ParseTree" => s(:defn, :splatted, s(:args, :"*args"),
|
547
|
+
s(:lasgn, :y,
|
548
|
+
s(:call, s(:lvar, :args), :first)),
|
549
|
+
s(:call, s(:lvar, :y), :+, s(:lit, 42))),
|
603
550
|
"Ruby2Ruby" => "def splatted(*args)\n y = args.first\n (y + 42)\nend")
|
604
551
|
|
605
552
|
add_tests("break",
|
606
553
|
"Ruby" => "loop { break if true }",
|
607
554
|
"ParseTree" => s(:iter,
|
608
|
-
s(:call, nil, :loop
|
555
|
+
s(:call, nil, :loop), nil,
|
609
556
|
s(:if, s(:true), s(:break), nil)))
|
610
557
|
|
611
558
|
add_tests("break_arg",
|
612
559
|
"Ruby" => "loop { break 42 if true }",
|
613
560
|
"ParseTree" => s(:iter,
|
614
|
-
s(:call, nil, :loop
|
561
|
+
s(:call, nil, :loop), nil,
|
615
562
|
s(:if, s(:true), s(:break, s(:lit, 42)), nil)))
|
616
563
|
|
617
564
|
add_tests("call",
|
618
565
|
"Ruby" => "self.method",
|
619
|
-
"ParseTree" => s(:call, s(:self), :method
|
566
|
+
"ParseTree" => s(:call, s(:self), :method))
|
620
567
|
|
621
568
|
add_tests("call_arglist",
|
622
569
|
"Ruby" => "o.puts(42)",
|
623
|
-
"ParseTree" => s(:call, s(:call, nil, :o, s(:
|
624
|
-
s(:arglist, s(:lit, 42))))
|
570
|
+
"ParseTree" => s(:call, s(:call, nil, :o), :puts, s(:lit, 42)))
|
625
571
|
|
626
572
|
add_tests("call_no_space_symbol",
|
627
573
|
"Ruby" => "foo:bar",
|
628
|
-
"ParseTree" => s(:call, nil, :foo, s(:
|
574
|
+
"ParseTree" => s(:call, nil, :foo, s(:lit, :bar)),
|
629
575
|
"Ruby2Ruby" => "foo(:bar)")
|
630
576
|
|
631
577
|
add_tests("ternary_symbol_no_spaces",
|
@@ -637,13 +583,16 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
637
583
|
"Ruby" => "1 ? m(a: 2) : 1",
|
638
584
|
"ParseTree" => s(:if, s(:lit, 1),
|
639
585
|
s(:call, nil, :m,
|
640
|
-
s(:
|
641
|
-
s(:hash, s(:lit, :a), s(:lit, 2)))),
|
586
|
+
s(:hash, s(:lit, :a), s(:lit, 2))),
|
642
587
|
s(:lit, 1)))
|
643
588
|
|
644
589
|
add_19tests("label_in_bare_hash_in_array_in_ternary",
|
645
590
|
"Ruby" => "1 ? [:a, b: 2] : 1",
|
646
|
-
|
591
|
+
"ParseTree" => s(:if, s(:lit, 1),
|
592
|
+
s(:array,
|
593
|
+
s(:lit, :a),
|
594
|
+
s(:hash, s(:lit, :b), s(:lit, 2))),
|
595
|
+
s(:lit, 1)))
|
647
596
|
|
648
597
|
add_tests("ternary_nil_no_space",
|
649
598
|
"Ruby" => "1 ? nil: 1",
|
@@ -653,38 +602,34 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
653
602
|
add_tests("call_arglist_hash",
|
654
603
|
"Ruby" => "o.m(:a => 1, :b => 2)",
|
655
604
|
"ParseTree" => s(:call,
|
656
|
-
s(:call, nil, :o
|
657
|
-
s(:
|
658
|
-
s(:
|
659
|
-
|
660
|
-
s(:lit, :b), s(:lit, 2)))))
|
605
|
+
s(:call, nil, :o), :m,
|
606
|
+
s(:hash,
|
607
|
+
s(:lit, :a), s(:lit, 1),
|
608
|
+
s(:lit, :b), s(:lit, 2))))
|
661
609
|
|
662
610
|
add_tests("call_arglist_norm_hash",
|
663
611
|
"Ruby" => "o.m(42, :a => 1, :b => 2)",
|
664
612
|
"ParseTree" => s(:call,
|
665
|
-
s(:call, nil, :o
|
666
|
-
s(:
|
667
|
-
|
668
|
-
s(:
|
669
|
-
|
670
|
-
s(:lit, :b), s(:lit, 2)))))
|
613
|
+
s(:call, nil, :o), :m,
|
614
|
+
s(:lit, 42),
|
615
|
+
s(:hash,
|
616
|
+
s(:lit, :a), s(:lit, 1),
|
617
|
+
s(:lit, :b), s(:lit, 2))))
|
671
618
|
|
672
619
|
add_tests("call_arglist_norm_hash_splat",
|
673
620
|
"Ruby" => "o.m(42, :a => 1, :b => 2, *c)",
|
674
621
|
"ParseTree" => s(:call,
|
675
|
-
s(:call, nil, :o
|
676
|
-
s(:
|
677
|
-
|
678
|
-
s(:
|
679
|
-
|
680
|
-
|
681
|
-
s(:splat, s(:call, nil, :c, s(:arglist))))))
|
622
|
+
s(:call, nil, :o), :m,
|
623
|
+
s(:lit, 42),
|
624
|
+
s(:hash,
|
625
|
+
s(:lit, :a), s(:lit, 1),
|
626
|
+
s(:lit, :b), s(:lit, 2)),
|
627
|
+
s(:splat, s(:call, nil, :c))))
|
682
628
|
|
683
629
|
add_tests("call_arglist_space",
|
684
630
|
"Ruby" => "a (1,2,3)",
|
685
631
|
"ParseTree" => s(:call, nil, :a,
|
686
|
-
s(:
|
687
|
-
s(:lit, 1), s(:lit, 2), s(:lit, 3))),
|
632
|
+
s(:lit, 1), s(:lit, 2), s(:lit, 3)),
|
688
633
|
"Ruby2Ruby" => "a(1, 2, 3)")
|
689
634
|
|
690
635
|
add_tests("call_command",
|
@@ -692,44 +637,38 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
692
637
|
"ParseTree" => s(:call,
|
693
638
|
s(:lit, 1),
|
694
639
|
:b,
|
695
|
-
s(:
|
640
|
+
s(:call, nil, :c)))
|
696
641
|
|
697
642
|
add_tests("call_expr",
|
698
643
|
"Ruby" => "(v = (1 + 1)).zero?",
|
699
644
|
"ParseTree" => s(:call,
|
700
645
|
s(:lasgn, :v,
|
701
|
-
s(:call, s(:lit, 1), :+,
|
702
|
-
|
703
|
-
:zero?, s(:arglist)))
|
646
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1))),
|
647
|
+
:zero?))
|
704
648
|
|
705
649
|
add_tests("call_index",
|
706
650
|
"Ruby" => "a = []\na[42]\n",
|
707
651
|
"ParseTree" => s(:block,
|
708
652
|
s(:lasgn, :a, s(:array)),
|
709
|
-
s(:call, s(:lvar, :a), :[],
|
710
|
-
s(:arglist, s(:lit, 42)))))
|
653
|
+
s(:call, s(:lvar, :a), :[], s(:lit, 42))))
|
711
654
|
|
712
655
|
add_tests("call_index_no_args",
|
713
656
|
"Ruby" => "a[]",
|
714
|
-
"ParseTree" => s(:call, s(:call, nil, :a
|
715
|
-
:[]
|
657
|
+
"ParseTree" => s(:call, s(:call, nil, :a),
|
658
|
+
:[]))
|
716
659
|
|
717
660
|
add_tests("call_index_space",
|
718
661
|
"Ruby" => "a = []\na [42]\n",
|
719
662
|
"ParseTree" => s(:block,
|
720
663
|
s(:lasgn, :a, s(:array)),
|
721
|
-
s(:call, s(:lvar, :a), :[],
|
722
|
-
s(:arglist, s(:lit, 42)))),
|
664
|
+
s(:call, s(:lvar, :a), :[], s(:lit, 42))),
|
723
665
|
"Ruby2Ruby" => "a = []\na[42]\n")
|
724
666
|
|
725
667
|
add_tests("call_unary_neg",
|
726
668
|
"Ruby" => "-2**31",
|
727
669
|
"ParseTree" => s(:call,
|
728
|
-
s(:call,
|
729
|
-
|
730
|
-
:**,
|
731
|
-
s(:arglist, s(:lit, 31))),
|
732
|
-
:-@, s(:arglist)),
|
670
|
+
s(:call, s(:lit, 2), :**, s(:lit, 31)),
|
671
|
+
:-@),
|
733
672
|
"Ruby2Ruby" => "-(2 ** 31)")
|
734
673
|
|
735
674
|
add_tests("case",
|
@@ -741,10 +680,8 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
741
680
|
s(:lvar, :var),
|
742
681
|
s(:when,
|
743
682
|
s(:array, s(:lit, 1)),
|
744
|
-
s(:
|
745
|
-
|
746
|
-
s(:arglist, s(:str, "something"))),
|
747
|
-
s(:lasgn, :result, s(:str, "red")))),
|
683
|
+
s(:call, nil, :puts, s(:str, "something")),
|
684
|
+
s(:lasgn, :result, s(:str, "red"))),
|
748
685
|
s(:when,
|
749
686
|
s(:array, s(:lit, 2), s(:lit, 3)),
|
750
687
|
s(:lasgn, :result, s(:str, "yellow"))),
|
@@ -788,16 +725,16 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
788
725
|
|
789
726
|
add_tests("case_nested_inner_no_expr",
|
790
727
|
"Ruby" => "case a\nwhen b then\n case\n when (d and e) then\n f\n else\n # do nothing\n end\nelse\n # do nothing\nend",
|
791
|
-
"ParseTree" => s(:case, s(:call, nil, :a
|
728
|
+
"ParseTree" => s(:case, s(:call, nil, :a),
|
792
729
|
s(:when,
|
793
|
-
s(:array, s(:call, nil, :b
|
730
|
+
s(:array, s(:call, nil, :b)),
|
794
731
|
s(:case, nil,
|
795
732
|
s(:when,
|
796
733
|
s(:array,
|
797
734
|
s(:and,
|
798
|
-
s(:call, nil, :d
|
799
|
-
s(:call, nil, :e
|
800
|
-
s(:call, nil, :f
|
735
|
+
s(:call, nil, :d),
|
736
|
+
s(:call, nil, :e))),
|
737
|
+
s(:call, nil, :f)),
|
801
738
|
nil)),
|
802
739
|
nil))
|
803
740
|
|
@@ -807,84 +744,64 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
807
744
|
s(:when,
|
808
745
|
s(:array,
|
809
746
|
s(:call,
|
810
|
-
s(:call, nil, :a
|
747
|
+
s(:call, nil, :a),
|
811
748
|
:==,
|
812
|
-
s(:
|
749
|
+
s(:lit, 1))),
|
813
750
|
s(:lit, :a)),
|
814
751
|
s(:when,
|
815
752
|
s(:array,
|
816
753
|
s(:call,
|
817
|
-
s(:call, nil, :a
|
754
|
+
s(:call, nil, :a),
|
818
755
|
:==,
|
819
|
-
s(:
|
756
|
+
s(:lit, 2))),
|
820
757
|
s(:lit, :b)),
|
821
758
|
s(:lit, :c)))
|
822
759
|
|
823
760
|
add_tests("case_splat",
|
824
761
|
"Ruby" => "case a\nwhen :b, *c then\n d\nelse\n e\nend",
|
825
|
-
"ParseTree" => s(:case, s(:call, nil, :a
|
762
|
+
"ParseTree" => s(:case, s(:call, nil, :a),
|
826
763
|
s(:when,
|
827
764
|
s(:array,
|
828
765
|
s(:lit, :b),
|
829
766
|
s(:when,
|
830
|
-
s(:call, nil, :c
|
767
|
+
s(:call, nil, :c),
|
831
768
|
nil)), # wtf?
|
832
|
-
s(:call, nil, :d
|
833
|
-
s(:call, nil, :e
|
769
|
+
s(:call, nil, :d)),
|
770
|
+
s(:call, nil, :e)))
|
834
771
|
|
835
772
|
add_tests("cdecl",
|
836
773
|
"Ruby" => "X = 42",
|
837
774
|
"ParseTree" => s(:cdecl, :X, s(:lit, 42)))
|
838
775
|
|
839
776
|
add_tests("class_plain",
|
840
|
-
"Ruby" => "class X\n puts((1 + 1))\n def blah\n puts(\"hello\")\n end\nend",
|
841
|
-
"ParseTree" => s(:class,
|
842
|
-
:
|
843
|
-
|
844
|
-
s(:
|
845
|
-
s(:
|
846
|
-
s(:call, nil, :puts,
|
847
|
-
s(:arglist,
|
848
|
-
s(:call, s(:lit, 1), :+,
|
849
|
-
s(:arglist, s(:lit, 1))))),
|
850
|
-
s(:defn, :blah,
|
851
|
-
s(:args),
|
852
|
-
s(:scope,
|
853
|
-
s(:block,
|
854
|
-
s(:call, nil, :puts,
|
855
|
-
s(:arglist,
|
856
|
-
s(:str, "hello"))))))))))
|
777
|
+
"Ruby" => "class X\n puts((1 + 1))\n \n def blah\n puts(\"hello\")\n end\nend",
|
778
|
+
"ParseTree" => s(:class, :X, nil,
|
779
|
+
s(:call, nil, :puts,
|
780
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1))),
|
781
|
+
s(:defn, :blah, s(:args),
|
782
|
+
s(:call, nil, :puts, s(:str, "hello")))))
|
857
783
|
|
858
784
|
add_tests("class_scoped",
|
859
785
|
"Ruby" => "class X::Y\n c\nend",
|
860
786
|
"ParseTree" => s(:class, s(:colon2, s(:const, :X), :Y), nil,
|
861
|
-
s(:
|
787
|
+
s(:call, nil, :c)))
|
862
788
|
|
863
789
|
add_tests("class_scoped3",
|
864
790
|
"Ruby" => "class ::Y\n c\nend",
|
865
791
|
"ParseTree" => s(:class, s(:colon3, :Y), nil,
|
866
|
-
s(:
|
792
|
+
s(:call, nil, :c)))
|
867
793
|
|
868
794
|
add_tests("class_super_array",
|
869
795
|
"Ruby" => "class X < Array\nend",
|
870
|
-
"ParseTree" => s(:class,
|
871
|
-
:X,
|
872
|
-
s(:const, :Array),
|
873
|
-
s(:scope)))
|
796
|
+
"ParseTree" => s(:class, :X, s(:const, :Array)))
|
874
797
|
|
875
798
|
add_tests("class_super_expr",
|
876
799
|
"Ruby" => "class X < expr\nend",
|
877
|
-
"ParseTree" => s(:class,
|
878
|
-
:X,
|
879
|
-
s(:call, nil, :expr, s(:arglist)),
|
880
|
-
s(:scope)))
|
800
|
+
"ParseTree" => s(:class, :X, s(:call, nil, :expr)))
|
881
801
|
|
882
802
|
add_tests("class_super_object",
|
883
803
|
"Ruby" => "class X < Object\nend",
|
884
|
-
"ParseTree" => s(:class,
|
885
|
-
:X,
|
886
|
-
s(:const, :Object),
|
887
|
-
s(:scope)))
|
804
|
+
"ParseTree" => s(:class, :X, s(:const, :Object)))
|
888
805
|
|
889
806
|
add_tests("colon2",
|
890
807
|
"Ruby" => "X::Y",
|
@@ -918,84 +835,67 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
918
835
|
|
919
836
|
add_tests("cvasgn",
|
920
837
|
"Ruby" => "def x\n @@blah = 1\nend",
|
921
|
-
"ParseTree" => s(:defn, :x,
|
922
|
-
s(:
|
923
|
-
s(:scope,
|
924
|
-
s(:block,
|
925
|
-
s(:cvasgn, :@@blah, s(:lit, 1))))))
|
838
|
+
"ParseTree" => s(:defn, :x, s(:args),
|
839
|
+
s(:cvasgn, :@@blah, s(:lit, 1))))
|
926
840
|
|
927
841
|
add_tests("cvasgn_cls_method",
|
928
842
|
"Ruby" => "def self.quiet_mode=(boolean)\n @@quiet_mode = boolean\nend",
|
929
843
|
"ParseTree" => s(:defs, s(:self), :quiet_mode=,
|
930
844
|
s(:args, :boolean),
|
931
|
-
s(:
|
932
|
-
s(:
|
933
|
-
s(:cvasgn, :@@quiet_mode,
|
934
|
-
s(:lvar, :boolean))))))
|
845
|
+
s(:cvasgn, :@@quiet_mode,
|
846
|
+
s(:lvar, :boolean))))
|
935
847
|
|
936
848
|
add_tests("cvdecl",
|
937
849
|
"Ruby" => "class X\n @@blah = 1\nend",
|
938
850
|
"ParseTree" => s(:class, :X, nil,
|
939
|
-
s(:
|
851
|
+
s(:cvdecl, :@@blah, s(:lit, 1))))
|
940
852
|
|
941
853
|
add_tests("dasgn_0",
|
942
854
|
"Ruby" => "a.each { |x| b.each { |y| x = (x + 1) } if true }",
|
943
855
|
"ParseTree" => s(:iter,
|
944
|
-
s(:call, s(:call, nil, :a
|
945
|
-
s(:arglist)),
|
856
|
+
s(:call, s(:call, nil, :a), :each),
|
946
857
|
s(:lasgn, :x),
|
947
858
|
s(:if, s(:true),
|
948
859
|
s(:iter,
|
949
|
-
s(:call, s(:call, nil, :b,
|
950
|
-
:each,
|
951
|
-
s(:arglist)),
|
860
|
+
s(:call, s(:call, nil, :b), :each),
|
952
861
|
s(:lasgn, :y),
|
953
862
|
s(:lasgn, :x,
|
954
|
-
s(:call, s(:lvar, :x), :+,
|
955
|
-
s(:arglist, s(:lit, 1))))),
|
863
|
+
s(:call, s(:lvar, :x), :+, s(:lit, 1)))),
|
956
864
|
nil)))
|
957
865
|
|
958
866
|
add_tests("dasgn_1",
|
959
867
|
"Ruby" => "a.each { |x| b.each { |y| c = (c + 1) } if true }",
|
960
868
|
"ParseTree" => s(:iter,
|
961
|
-
s(:call, s(:call, nil, :a
|
962
|
-
s(:arglist)),
|
869
|
+
s(:call, s(:call, nil, :a), :each),
|
963
870
|
s(:lasgn, :x),
|
964
871
|
s(:if, s(:true),
|
965
872
|
s(:iter,
|
966
|
-
s(:call, s(:call, nil, :b,
|
967
|
-
:each,
|
968
|
-
s(:arglist)),
|
873
|
+
s(:call, s(:call, nil, :b), :each),
|
969
874
|
s(:lasgn, :y),
|
970
875
|
s(:lasgn, :c,
|
971
|
-
s(:call, s(:lvar, :c), :+,
|
972
|
-
s(:arglist, s(:lit, 1))))),
|
876
|
+
s(:call, s(:lvar, :c), :+, s(:lit, 1)))),
|
973
877
|
nil)))
|
974
878
|
|
975
879
|
add_tests("dasgn_2",
|
976
880
|
"Ruby" => "a.each do |x|\n if true then\n c = 0\n b.each { |y| c = (c + 1) }\n end\nend", # FIX: hate that extra newline!
|
977
881
|
"ParseTree" => s(:iter,
|
978
|
-
s(:call, s(:call, nil, :a
|
979
|
-
s(:arglist)),
|
882
|
+
s(:call, s(:call, nil, :a), :each),
|
980
883
|
s(:lasgn, :x),
|
981
884
|
s(:if, s(:true),
|
982
885
|
s(:block,
|
983
886
|
s(:lasgn, :c, s(:lit, 0)),
|
984
887
|
s(:iter,
|
985
|
-
s(:call, s(:call, nil, :b,
|
986
|
-
:each,
|
987
|
-
s(:arglist)),
|
888
|
+
s(:call, s(:call, nil, :b), :each),
|
988
889
|
s(:lasgn, :y),
|
989
890
|
s(:lasgn, :c,
|
990
891
|
s(:call, s(:lvar, :c), :+,
|
991
|
-
s(:
|
892
|
+
s(:lit, 1))))),
|
992
893
|
nil)))
|
993
894
|
|
994
895
|
add_tests("dasgn_curr",
|
995
896
|
"Ruby" => "data.each do |x, y|\n a = 1\n b = a\n b = a = x\nend",
|
996
897
|
"ParseTree" => s(:iter,
|
997
|
-
s(:call, s(:call, nil, :data,
|
998
|
-
s(:arglist)), :each, s(:arglist)),
|
898
|
+
s(:call, s(:call, nil, :data), :each),
|
999
899
|
s(:masgn,
|
1000
900
|
s(:array, s(:lasgn, :x), s(:lasgn, :y))),
|
1001
901
|
s(:block,
|
@@ -1006,15 +906,13 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1006
906
|
add_tests("dasgn_icky",
|
1007
907
|
"Ruby" => "a do\n v = nil\n assert_block(full_message) do\n begin\n yield\n rescue Exception => v\n break\n end\n end\nend",
|
1008
908
|
"ParseTree" => s(:iter,
|
1009
|
-
s(:call, nil, :a
|
909
|
+
s(:call, nil, :a),
|
1010
910
|
nil,
|
1011
911
|
s(:block,
|
1012
912
|
s(:lasgn, :v, s(:nil)),
|
1013
913
|
s(:iter,
|
1014
914
|
s(:call, nil, :assert_block,
|
1015
|
-
s(:
|
1016
|
-
s(:call, nil, :full_message,
|
1017
|
-
s(:arglist)))),
|
915
|
+
s(:call, nil, :full_message)),
|
1018
916
|
nil,
|
1019
917
|
s(:rescue,
|
1020
918
|
s(:yield),
|
@@ -1029,12 +927,10 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1029
927
|
"ParseTree" => s(:block,
|
1030
928
|
s(:lasgn, :t, s(:lit, 0)),
|
1031
929
|
s(:iter,
|
1032
|
-
s(:call, s(:call, nil, :ns,
|
1033
|
-
s(:arglist)), :each, s(:arglist)),
|
930
|
+
s(:call, s(:call, nil, :ns), :each),
|
1034
931
|
s(:lasgn, :n),
|
1035
932
|
s(:lasgn, :t,
|
1036
|
-
s(:call, s(:lvar, :t), :+,
|
1037
|
-
s(:arglist, s(:lvar, :n)))))),
|
933
|
+
s(:call, s(:lvar, :t), :+, s(:lvar, :n))))),
|
1038
934
|
"Ruby2Ruby" => "t = 0\nns.each { |n| t = (t + n) }\n")
|
1039
935
|
|
1040
936
|
add_tests("defined",
|
@@ -1044,21 +940,18 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1044
940
|
# TODO: make all the defn_args* p their arglist
|
1045
941
|
add_tests("defn_args_block",
|
1046
942
|
"Ruby" => "def f(&block)\n # do nothing\nend",
|
1047
|
-
"ParseTree" => s(:defn, :f,
|
1048
|
-
s(:
|
1049
|
-
s(:scope, s(:block, s(:nil)))))
|
943
|
+
"ParseTree" => s(:defn, :f, s(:args, :"&block"),
|
944
|
+
s(:nil)))
|
1050
945
|
|
1051
946
|
add_tests("defn_args_mand",
|
1052
947
|
"Ruby" => "def f(mand)\n # do nothing\nend",
|
1053
|
-
"ParseTree" => s(:defn, :f,
|
1054
|
-
s(:
|
1055
|
-
s(:scope, s(:block, s(:nil)))))
|
948
|
+
"ParseTree" => s(:defn, :f, s(:args, :mand),
|
949
|
+
s(:nil)))
|
1056
950
|
|
1057
951
|
add_tests("defn_args_mand_block",
|
1058
952
|
"Ruby" => "def f(mand, &block)\n # do nothing\nend",
|
1059
|
-
"ParseTree" => s(:defn, :f,
|
1060
|
-
|
1061
|
-
s(:scope, s(:block, s(:nil)))))
|
953
|
+
"ParseTree" => s(:defn, :f, s(:args, :mand, :"&block"),
|
954
|
+
s(:nil)))
|
1062
955
|
|
1063
956
|
add_tests("defn_args_mand_opt",
|
1064
957
|
"Ruby" => "def f(mand, opt = 42)\n # do nothing\nend",
|
@@ -1066,7 +959,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1066
959
|
s(:args, :mand, :opt,
|
1067
960
|
s(:block,
|
1068
961
|
s(:lasgn, :opt, s(:lit, 42)))),
|
1069
|
-
s(:
|
962
|
+
s(:nil)))
|
1070
963
|
|
1071
964
|
add_tests("defn_args_mand_opt_block",
|
1072
965
|
"Ruby" => "def f(mand, opt = 42, &block)\n # do nothing\nend",
|
@@ -1074,7 +967,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1074
967
|
s(:args, :mand, :opt, :"&block",
|
1075
968
|
s(:block,
|
1076
969
|
s(:lasgn, :opt, s(:lit, 42)))),
|
1077
|
-
s(:
|
970
|
+
s(:nil)))
|
1078
971
|
|
1079
972
|
add_tests("defn_args_mand_opt_splat",
|
1080
973
|
"Ruby" => "def f(mand, opt = 42, *rest)\n # do nothing\nend",
|
@@ -1082,7 +975,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1082
975
|
s(:args, :mand, :opt, :"*rest",
|
1083
976
|
s(:block,
|
1084
977
|
s(:lasgn, :opt, s(:lit, 42)))),
|
1085
|
-
s(:
|
978
|
+
s(:nil)))
|
1086
979
|
|
1087
980
|
add_tests("defn_args_mand_opt_splat_block",
|
1088
981
|
"Ruby" => "def f(mand, opt = 42, *rest, &block)\n # do nothing\nend",
|
@@ -1090,43 +983,37 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1090
983
|
s(:args, :mand, :opt, :"*rest", :"&block",
|
1091
984
|
s(:block,
|
1092
985
|
s(:lasgn, :opt, s(:lit, 42)))),
|
1093
|
-
s(:
|
986
|
+
s(:nil)))
|
1094
987
|
|
1095
988
|
add_tests("defn_args_mand_opt_splat_no_name",
|
1096
989
|
"Ruby" => "def x(a, b = 42, *)\n # do nothing\nend",
|
1097
990
|
"ParseTree" => s(:defn, :x,
|
1098
991
|
s(:args, :a, :b, :"*",
|
1099
992
|
s(:block, s(:lasgn, :b, s(:lit, 42)))),
|
1100
|
-
s(:
|
1101
|
-
s(:block,
|
1102
|
-
s(:nil)))))
|
993
|
+
s(:nil)))
|
1103
994
|
|
1104
995
|
add_tests("defn_args_mand_splat",
|
1105
996
|
"Ruby" => "def f(mand, *rest)\n # do nothing\nend",
|
1106
997
|
"ParseTree" => s(:defn, :f,
|
1107
998
|
s(:args, :mand, :"*rest"),
|
1108
|
-
s(:
|
1109
|
-
|
999
|
+
s(:nil)))
|
1000
|
+
|
1110
1001
|
add_tests("defn_args_mand_splat_block",
|
1111
1002
|
"Ruby" => "def f(mand, *rest, &block)\n # do nothing\nend",
|
1112
1003
|
"ParseTree" => s(:defn, :f,
|
1113
1004
|
s(:args, :mand, :"*rest", :"&block"),
|
1114
|
-
s(:
|
1005
|
+
s(:nil)))
|
1115
1006
|
|
1116
1007
|
add_tests("defn_args_mand_splat_no_name",
|
1117
1008
|
"Ruby" => "def x(a, *args)\n p(a, args)\nend",
|
1118
|
-
"ParseTree" => s(:defn, :x,
|
1119
|
-
s(:
|
1120
|
-
|
1121
|
-
s(:block,
|
1122
|
-
s(:call, nil, :p,
|
1123
|
-
s(:arglist, s(:lvar, :a), s(:lvar, :args)))))))
|
1009
|
+
"ParseTree" => s(:defn, :x, s(:args, :a, :"*args"),
|
1010
|
+
s(:call, nil, :p,
|
1011
|
+
s(:lvar, :a), s(:lvar, :args))))
|
1124
1012
|
|
1125
1013
|
add_tests("defn_args_none",
|
1126
1014
|
"Ruby" => "def empty\n # do nothing\nend",
|
1127
|
-
"ParseTree" => s(:defn, :empty,
|
1128
|
-
s(:
|
1129
|
-
s(:scope, s(:block, s(:nil)))))
|
1015
|
+
"ParseTree" => s(:defn, :empty, s(:args),
|
1016
|
+
s(:nil)))
|
1130
1017
|
|
1131
1018
|
add_tests("defn_args_opt",
|
1132
1019
|
"Ruby" => "def f(opt = 42)\n # do nothing\nend",
|
@@ -1134,7 +1021,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1134
1021
|
s(:args, :opt,
|
1135
1022
|
s(:block,
|
1136
1023
|
s(:lasgn, :opt, s(:lit, 42)))),
|
1137
|
-
s(:
|
1024
|
+
s(:nil)))
|
1138
1025
|
|
1139
1026
|
add_tests("defn_args_opt_block",
|
1140
1027
|
"Ruby" => "def f(opt = 42, &block)\n # do nothing\nend",
|
@@ -1142,7 +1029,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1142
1029
|
s(:args, :opt, :"&block",
|
1143
1030
|
s(:block,
|
1144
1031
|
s(:lasgn, :opt, s(:lit, 42)))),
|
1145
|
-
|
1032
|
+
s(:nil)))
|
1146
1033
|
|
1147
1034
|
add_tests("defn_args_opt_splat",
|
1148
1035
|
"Ruby" => "def f(opt = 42, *rest)\n # do nothing\nend",
|
@@ -1150,7 +1037,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1150
1037
|
s(:args, :opt, :"*rest",
|
1151
1038
|
s(:block,
|
1152
1039
|
s(:lasgn, :opt, s(:lit, 42)))),
|
1153
|
-
s(:
|
1040
|
+
s(:nil)))
|
1154
1041
|
|
1155
1042
|
add_tests("defn_args_opt_splat_block",
|
1156
1043
|
"Ruby" => "def f(opt = 42, *rest, &block)\n # do nothing\nend",
|
@@ -1158,152 +1045,119 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1158
1045
|
s(:args, :opt, :"*rest", :"&block",
|
1159
1046
|
s(:block,
|
1160
1047
|
s(:lasgn, :opt, s(:lit, 42)))),
|
1161
|
-
s(:
|
1048
|
+
s(:nil)))
|
1162
1049
|
|
1163
1050
|
add_tests("defn_args_opt_splat_no_name",
|
1164
1051
|
"Ruby" => "def x(b = 42, *)\n # do nothing\nend",
|
1165
1052
|
"ParseTree" => s(:defn, :x,
|
1166
1053
|
s(:args, :b, :"*",
|
1167
1054
|
s(:block, s(:lasgn, :b, s(:lit, 42)))),
|
1168
|
-
s(:
|
1169
|
-
s(:block,
|
1170
|
-
s(:nil)))))
|
1055
|
+
s(:nil)))
|
1171
1056
|
|
1172
1057
|
add_tests("defn_args_splat",
|
1173
1058
|
"Ruby" => "def f(*rest)\n # do nothing\nend",
|
1174
|
-
"ParseTree" => s(:defn, :f,
|
1175
|
-
s(:
|
1176
|
-
s(:scope, s(:block, s(:nil)))))
|
1059
|
+
"ParseTree" => s(:defn, :f, s(:args, :"*rest"),
|
1060
|
+
s(:nil)))
|
1177
1061
|
|
1178
1062
|
add_tests("defn_args_splat_no_name",
|
1179
1063
|
"Ruby" => "def x(*)\n # do nothing\nend",
|
1180
|
-
"ParseTree" => s(:defn, :x,
|
1181
|
-
s(:
|
1182
|
-
s(:scope,
|
1183
|
-
s(:block,
|
1184
|
-
s(:nil)))))
|
1064
|
+
"ParseTree" => s(:defn, :x, s(:args, :"*"),
|
1065
|
+
s(:nil)))
|
1185
1066
|
|
1186
1067
|
add_tests("defn_or",
|
1187
1068
|
"Ruby" => "def |(o)\n # do nothing\nend",
|
1188
|
-
"ParseTree" => s(:defn, :|,
|
1189
|
-
s(:
|
1190
|
-
s(:scope, s(:block, s(:nil)))))
|
1069
|
+
"ParseTree" => s(:defn, :|, s(:args, :o),
|
1070
|
+
s(:nil)))
|
1191
1071
|
|
1192
1072
|
add_tests("defn_rescue",
|
1193
1073
|
"Ruby" => "def eql?(resource)\n (self.uuid == resource.uuid)\nrescue\n false\nend",
|
1194
1074
|
"ParseTree" => s(:defn, :eql?,
|
1195
1075
|
s(:args, :resource),
|
1196
|
-
s(:
|
1197
|
-
s(:
|
1198
|
-
s(:
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
s(:arglist,
|
1203
|
-
s(:call, s(:lvar, :resource),
|
1204
|
-
:uuid, s(:arglist)))),
|
1205
|
-
s(:resbody, s(:array), s(:false)))))),
|
1076
|
+
s(:rescue,
|
1077
|
+
s(:call,
|
1078
|
+
s(:call, s(:self), :uuid),
|
1079
|
+
:==,
|
1080
|
+
s(:call, s(:lvar, :resource), :uuid)),
|
1081
|
+
s(:resbody, s(:array), s(:false)))),
|
1206
1082
|
"Ruby2Ruby" => "def eql?(resource)\n (self.uuid == resource.uuid) rescue false\nend")
|
1207
1083
|
|
1208
1084
|
add_tests("defn_rescue_mri_verbose_flag",
|
1209
1085
|
"Ruby" => "def eql?(resource)\n (self.uuid == resource.uuid)\nrescue\n false\nend",
|
1210
1086
|
"ParseTree" => s(:defn, :eql?,
|
1211
1087
|
s(:args, :resource),
|
1212
|
-
s(:
|
1213
|
-
s(:
|
1214
|
-
s(:
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
s(:arglist,
|
1219
|
-
s(:call, s(:lvar, :resource),
|
1220
|
-
:uuid, s(:arglist)))),
|
1221
|
-
s(:resbody, s(:array), s(:false)))))),
|
1088
|
+
s(:rescue,
|
1089
|
+
s(:call,
|
1090
|
+
s(:call, s(:self), :uuid),
|
1091
|
+
:==,
|
1092
|
+
s(:call, s(:lvar, :resource), :uuid)),
|
1093
|
+
s(:resbody, s(:array), s(:false)))),
|
1222
1094
|
"Ruby2Ruby" => "def eql?(resource)\n (self.uuid == resource.uuid) rescue false\nend")
|
1223
1095
|
|
1224
1096
|
add_tests("defn_something_eh",
|
1225
1097
|
"Ruby" => "def something?\n # do nothing\nend",
|
1226
1098
|
"ParseTree" => s(:defn, :something?,
|
1227
1099
|
s(:args),
|
1228
|
-
s(:
|
1100
|
+
s(:nil)))
|
1229
1101
|
|
1230
1102
|
add_tests("defn_splat_no_name",
|
1231
1103
|
"Ruby" => "def x(a, *)\n p(a)\nend",
|
1232
1104
|
"ParseTree" => s(:defn, :x,
|
1233
1105
|
s(:args, :a, :"*"),
|
1234
|
-
s(:
|
1235
|
-
s(:block,
|
1236
|
-
s(:call, nil, :p,
|
1237
|
-
s(:arglist, s(:lvar, :a)))))))
|
1106
|
+
s(:call, nil, :p, s(:lvar, :a))))
|
1238
1107
|
|
1239
1108
|
add_tests("defn_zarray",
|
1240
1109
|
"Ruby" => "def zarray\n a = []\n return a\nend",
|
1241
1110
|
"ParseTree" => s(:defn, :zarray,
|
1242
1111
|
s(:args),
|
1243
|
-
s(:
|
1244
|
-
|
1245
|
-
s(:lasgn, :a, s(:array)),
|
1246
|
-
s(:return, s(:lvar, :a))))))
|
1112
|
+
s(:lasgn, :a, s(:array)),
|
1113
|
+
s(:return, s(:lvar, :a))))
|
1247
1114
|
|
1248
1115
|
add_tests("defs",
|
1249
1116
|
"Ruby" => "def self.x(y)\n (y + 1)\nend",
|
1250
1117
|
"ParseTree" => s(:defs, s(:self), :x,
|
1251
1118
|
s(:args, :y),
|
1252
|
-
s(:
|
1253
|
-
s(:block,
|
1254
|
-
s(:call, s(:lvar, :y), :+,
|
1255
|
-
s(:arglist, s(:lit, 1)))))))
|
1119
|
+
s(:call, s(:lvar, :y), :+, s(:lit, 1))))
|
1256
1120
|
|
1257
1121
|
add_tests("defs_empty",
|
1258
1122
|
"Ruby" => "def self.empty\n # do nothing\nend",
|
1259
|
-
"ParseTree" => s(:defs, s(:self), :empty,
|
1260
|
-
s(:args),
|
1261
|
-
s(:scope, s(:block))))
|
1123
|
+
"ParseTree" => s(:defs, s(:self), :empty, s(:args)))
|
1262
1124
|
|
1263
1125
|
add_tests("defs_empty_args",
|
1264
1126
|
"Ruby" => "def self.empty(*)\n # do nothing\nend",
|
1265
1127
|
"ParseTree" => s(:defs, s(:self), :empty,
|
1266
|
-
s(:args, :*)
|
1267
|
-
s(:scope, s(:block))))
|
1128
|
+
s(:args, :*)))
|
1268
1129
|
|
1269
1130
|
add_tests("defs_expr_wtf",
|
1270
1131
|
"Ruby" => "def (a.b).empty(*)\n # do nothing\nend",
|
1271
1132
|
"ParseTree" => s(:defs,
|
1272
|
-
s(:call,
|
1273
|
-
s(:call, nil, :a, s(:arglist)),
|
1274
|
-
:b, s(:arglist)),
|
1133
|
+
s(:call, s(:call, nil, :a), :b),
|
1275
1134
|
:empty,
|
1276
|
-
s(:args, :*)
|
1277
|
-
s(:scope, s(:block))))
|
1135
|
+
s(:args, :*)))
|
1278
1136
|
|
1279
1137
|
add_tests("dmethod",
|
1280
1138
|
"Ruby" => [Examples, :dmethod_added],
|
1281
1139
|
"ParseTree" => s(:defn, :dmethod_added,
|
1282
1140
|
s(:args, :x),
|
1283
|
-
s(:
|
1284
|
-
s(:block,
|
1285
|
-
s(:call, s(:lvar, :x), :+,
|
1286
|
-
s(:arglist, s(:lit, 1)))))),
|
1141
|
+
s(:call, s(:lvar, :x), :+, s(:lit, 1))),
|
1287
1142
|
"Ruby2Ruby" => "def dmethod_added(x)\n (x + 1)\nend")
|
1288
1143
|
|
1289
1144
|
add_tests("dot2",
|
1290
1145
|
"Ruby" => "(a..b)",
|
1291
1146
|
"ParseTree" => s(:dot2,
|
1292
|
-
s(:call, nil, :a
|
1293
|
-
s(:call, nil, :b
|
1147
|
+
s(:call, nil, :a),
|
1148
|
+
s(:call, nil, :b)))
|
1294
1149
|
|
1295
1150
|
add_tests("dot3",
|
1296
1151
|
"Ruby" => "(a...b)",
|
1297
1152
|
"ParseTree" => s(:dot3,
|
1298
|
-
s(:call, nil, :a
|
1299
|
-
s(:call, nil, :b
|
1153
|
+
s(:call, nil, :a),
|
1154
|
+
s(:call, nil, :b)))
|
1300
1155
|
|
1301
1156
|
add_tests("dregx",
|
1302
1157
|
"Ruby" => "/x#\{(1 + 1)}y/",
|
1303
1158
|
"ParseTree" => s(:dregx, "x",
|
1304
1159
|
s(:evstr,
|
1305
|
-
s(:call, s(:lit, 1), :+,
|
1306
|
-
s(:arglist, s(:lit, 1)))),
|
1160
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1))),
|
1307
1161
|
s(:str, "y")))
|
1308
1162
|
|
1309
1163
|
add_tests("dregx_interp",
|
@@ -1323,8 +1177,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1323
1177
|
"Ruby" => "/x#\{(1 + 1)}y/o",
|
1324
1178
|
"ParseTree" => s(:dregx_once, "x",
|
1325
1179
|
s(:evstr,
|
1326
|
-
s(:call, s(:lit, 1), :+,
|
1327
|
-
s(:arglist, s(:lit, 1)))),
|
1180
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1))),
|
1328
1181
|
s(:str, "y")))
|
1329
1182
|
|
1330
1183
|
add_tests("dregx_once_n_interp",
|
@@ -1348,7 +1201,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1348
1201
|
"x",
|
1349
1202
|
s(:evstr,
|
1350
1203
|
s(:call, s(:str, "%.2f"), :%,
|
1351
|
-
s(:
|
1204
|
+
s(:lit, 3.14159))),
|
1352
1205
|
s(:str, "y"))))
|
1353
1206
|
|
1354
1207
|
add_tests("dstr_3",
|
@@ -1363,7 +1216,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1363
1216
|
s(:evstr, s(:lvar, :max)),
|
1364
1217
|
s(:str, "f")),
|
1365
1218
|
:%,
|
1366
|
-
s(:
|
1219
|
+
s(:lit, 3.14159))),
|
1367
1220
|
s(:str, "y"))))
|
1368
1221
|
|
1369
1222
|
add_tests("dstr_concat",
|
@@ -1392,8 +1245,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1392
1245
|
add_tests("dstr_heredoc_expand",
|
1393
1246
|
"Ruby" => "<<EOM\n blah\n#\{1 + 1}blah\nEOM\n",
|
1394
1247
|
"ParseTree" => s(:dstr, " blah\n",
|
1395
|
-
s(:evstr, s(:call, s(:lit, 1), :+,
|
1396
|
-
s(:arglist, s(:lit, 1)))),
|
1248
|
+
s(:evstr, s(:call, s(:lit, 1), :+, s(:lit, 1))),
|
1397
1249
|
s(:str, "blah\n")),
|
1398
1250
|
"Ruby2Ruby" => "\" blah\\n#\{(1 + 1)}blah\\n\"")
|
1399
1251
|
|
@@ -1401,7 +1253,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1401
1253
|
"Ruby" => "<<-EOF\r\ndef test_#\{action}_valid_feed\r\n EOF\r\n",
|
1402
1254
|
"ParseTree" => s(:dstr,
|
1403
1255
|
'def test_',
|
1404
|
-
s(:evstr, s(:call, nil, :action
|
1256
|
+
s(:evstr, s(:call, nil, :action)),
|
1405
1257
|
s(:str, "_valid_feed\n")),
|
1406
1258
|
"Ruby2Ruby" => "\"def test_#\{action}_valid_feed\\n\"")
|
1407
1259
|
|
@@ -1417,7 +1269,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1417
1269
|
add_tests("dstr_nest",
|
1418
1270
|
"Ruby" => "%Q[before [#\{nest}] after]",
|
1419
1271
|
"ParseTree" => s(:dstr, "before [",
|
1420
|
-
s(:evstr, s(:call, nil, :nest
|
1272
|
+
s(:evstr, s(:call, nil, :nest)),
|
1421
1273
|
s(:str, "] after")),
|
1422
1274
|
"Ruby2Ruby" => "\"before [#\{nest}] after\"")
|
1423
1275
|
|
@@ -1427,11 +1279,9 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1427
1279
|
"blah(string):",
|
1428
1280
|
s(:evstr, s(:lit, 1)),
|
1429
1281
|
s(:str, ": warning: "),
|
1430
|
-
s(:evstr, s(:call, s(:gvar, :$!), :message,
|
1431
|
-
s(:arglist))),
|
1282
|
+
s(:evstr, s(:call, s(:gvar, :$!), :message)),
|
1432
1283
|
s(:str, " ("),
|
1433
|
-
s(:evstr, s(:call, s(:gvar, :$!), :class,
|
1434
|
-
s(:arglist))),
|
1284
|
+
s(:evstr, s(:call, s(:gvar, :$!), :class)),
|
1435
1285
|
s(:str, ")")),
|
1436
1286
|
"Ruby2Ruby" => '"blah(string):#{1}: warning: #{$!.message} (#{$!.class})"')
|
1437
1287
|
|
@@ -1439,9 +1289,9 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1439
1289
|
"Ruby" => '"before #{from} middle #{to} (#{__FILE__}:#{__LINE__})"',
|
1440
1290
|
"ParseTree" => s(:dstr,
|
1441
1291
|
"before ",
|
1442
|
-
s(:evstr, s(:call, nil, :from
|
1292
|
+
s(:evstr, s(:call, nil, :from)),
|
1443
1293
|
s(:str, " middle "),
|
1444
|
-
s(:evstr, s(:call, nil, :to
|
1294
|
+
s(:evstr, s(:call, nil, :to)),
|
1445
1295
|
s(:str, " ("),
|
1446
1296
|
s(:str, "(string)"),
|
1447
1297
|
s(:str, ":"),
|
@@ -1452,8 +1302,8 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1452
1302
|
add_tests("dsym",
|
1453
1303
|
"Ruby" => ":\"x#\{(1 + 1)}y\"",
|
1454
1304
|
"ParseTree" => s(:dsym, "x",
|
1455
|
-
s(:evstr, s(:call, s(:lit, 1), :+,
|
1456
|
-
|
1305
|
+
s(:evstr, s(:call, s(:lit, 1), :+, s(:lit, 1))),
|
1306
|
+
s(:str, "y")))
|
1457
1307
|
|
1458
1308
|
add_tests("dxstr",
|
1459
1309
|
"Ruby" => "t = 5\n`touch #\{t}`\n",
|
@@ -1465,8 +1315,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1465
1315
|
"Ruby" => "begin\n (1 + 1)\nrescue SyntaxError => e1\n 2\nrescue Exception => e2\n 3\nelse\n 4\nensure\n 5\nend",
|
1466
1316
|
"ParseTree" => s(:ensure,
|
1467
1317
|
s(:rescue,
|
1468
|
-
s(:call, s(:lit, 1), :+,
|
1469
|
-
s(:arglist, s(:lit, 1))),
|
1318
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1)),
|
1470
1319
|
s(:resbody,
|
1471
1320
|
s(:array,
|
1472
1321
|
s(:const, :SyntaxError),
|
@@ -1486,72 +1335,60 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1486
1335
|
|
1487
1336
|
add_tests("fbody",
|
1488
1337
|
"Ruby" => [Examples, :an_alias],
|
1489
|
-
"ParseTree" => s(:defn, :an_alias,
|
1490
|
-
s(:
|
1491
|
-
s(:scope,
|
1492
|
-
s(:block,
|
1493
|
-
s(:call, s(:lvar, :x), :+,
|
1494
|
-
s(:arglist, s(:lit, 1)))))),
|
1338
|
+
"ParseTree" => s(:defn, :an_alias, s(:args, :x),
|
1339
|
+
s(:call, s(:lvar, :x), :+, s(:lit, 1))),
|
1495
1340
|
"Ruby2Ruby" => "def an_alias(x)\n (x + 1)\nend")
|
1496
1341
|
|
1497
1342
|
add_tests("fcall_arglist",
|
1498
1343
|
"Ruby" => "m(42)",
|
1499
|
-
"ParseTree" => s(:call, nil, :m, s(:
|
1344
|
+
"ParseTree" => s(:call, nil, :m, s(:lit, 42)))
|
1500
1345
|
|
1501
1346
|
add_tests("fcall_arglist_hash",
|
1502
1347
|
"Ruby" => "m(:a => 1, :b => 2)",
|
1503
1348
|
"ParseTree" => s(:call, nil, :m,
|
1504
|
-
s(:
|
1505
|
-
s(:
|
1506
|
-
|
1507
|
-
s(:lit, :b), s(:lit, 2)))))
|
1349
|
+
s(:hash,
|
1350
|
+
s(:lit, :a), s(:lit, 1),
|
1351
|
+
s(:lit, :b), s(:lit, 2))))
|
1508
1352
|
|
1509
1353
|
add_tests("fcall_arglist_norm_hash",
|
1510
1354
|
"Ruby" => "m(42, :a => 1, :b => 2)",
|
1511
1355
|
"ParseTree" => s(:call, nil, :m,
|
1512
|
-
s(:
|
1513
|
-
|
1514
|
-
s(:
|
1515
|
-
|
1516
|
-
s(:lit, :b), s(:lit, 2)))))
|
1356
|
+
s(:lit, 42),
|
1357
|
+
s(:hash,
|
1358
|
+
s(:lit, :a), s(:lit, 1),
|
1359
|
+
s(:lit, :b), s(:lit, 2))))
|
1517
1360
|
|
1518
1361
|
add_tests("fcall_arglist_norm_hash_splat",
|
1519
1362
|
"Ruby" => "m(42, :a => 1, :b => 2, *c)",
|
1520
1363
|
"ParseTree" => s(:call, nil, :m,
|
1521
|
-
s(:
|
1522
|
-
|
1523
|
-
s(:
|
1524
|
-
|
1525
|
-
|
1526
|
-
s(:splat, s(:call, nil, :c, s(:arglist))))))
|
1364
|
+
s(:lit, 42),
|
1365
|
+
s(:hash,
|
1366
|
+
s(:lit, :a), s(:lit, 1),
|
1367
|
+
s(:lit, :b), s(:lit, 2)),
|
1368
|
+
s(:splat, s(:call, nil, :c))))
|
1527
1369
|
|
1528
1370
|
add_tests("fcall_block",
|
1529
1371
|
"Ruby" => "a(:b) { :c }",
|
1530
1372
|
"ParseTree" => s(:iter,
|
1531
|
-
s(:call, nil, :a,
|
1532
|
-
|
1373
|
+
s(:call, nil, :a, s(:lit, :b)),
|
1374
|
+
nil,
|
1533
1375
|
s(:lit, :c)))
|
1534
1376
|
|
1535
1377
|
add_tests("fcall_index_space",
|
1536
1378
|
"Ruby" => "a [42]",
|
1537
|
-
"ParseTree" => s(:call, nil, :a,
|
1538
|
-
s(:arglist, s(:array, s(:lit, 42)))),
|
1379
|
+
"ParseTree" => s(:call, nil, :a, s(:array, s(:lit, 42))),
|
1539
1380
|
"Ruby2Ruby" => "a([42])")
|
1540
1381
|
|
1541
1382
|
add_tests("fcall_keyword",
|
1542
1383
|
"Ruby" => "42 if block_given?",
|
1543
1384
|
"ParseTree" => s(:if,
|
1544
|
-
s(:call, nil, :block_given
|
1385
|
+
s(:call, nil, :block_given?),
|
1545
1386
|
s(:lit, 42), nil))
|
1546
1387
|
|
1547
1388
|
add_tests("fcall_inside_parens",
|
1548
1389
|
"Ruby" => "( a (b), c)",
|
1549
|
-
"ParseTree" => s(:call,
|
1550
|
-
nil,
|
1551
|
-
:a,
|
1552
|
-
s(:arglist,
|
1553
|
-
s(:call, nil, :b, s(:arglist)),
|
1554
|
-
s(:call, nil, :c, s(:arglist)))),
|
1390
|
+
"ParseTree" => s(:call, nil, :a,
|
1391
|
+
s(:call, nil, :b), s(:call, nil, :c)),
|
1555
1392
|
"Ruby2Ruby" => "a(b, c)")
|
1556
1393
|
|
1557
1394
|
add_tests("flip2",
|
@@ -1561,18 +1398,18 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1561
1398
|
s(:if,
|
1562
1399
|
s(:flip2,
|
1563
1400
|
s(:call,
|
1564
|
-
s(:call, s(:call, nil, :i
|
1401
|
+
s(:call, s(:call, nil, :i),
|
1565
1402
|
:%,
|
1566
|
-
s(:
|
1403
|
+
s(:lit, 4)),
|
1567
1404
|
:==,
|
1568
|
-
s(:
|
1405
|
+
s(:lit, 0)),
|
1569
1406
|
s(:call,
|
1570
|
-
s(:call, s(:call, nil, :i
|
1407
|
+
s(:call, s(:call, nil, :i),
|
1571
1408
|
:%,
|
1572
|
-
s(:
|
1409
|
+
s(:lit, 3)),
|
1573
1410
|
:==,
|
1574
|
-
s(:
|
1575
|
-
s(:call, nil, :i
|
1411
|
+
s(:lit, 0))),
|
1412
|
+
s(:call, nil, :i),
|
1576
1413
|
s(:nil))))
|
1577
1414
|
|
1578
1415
|
add_tests("flip2_method",
|
@@ -1580,9 +1417,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1580
1417
|
"ParseTree" => s(:if,
|
1581
1418
|
s(:flip2,
|
1582
1419
|
s(:lit, 1),
|
1583
|
-
s(:call, s(:lit, 2), :a?,
|
1584
|
-
s(:arglist,
|
1585
|
-
s(:call, nil, :b, s(:arglist))))),
|
1420
|
+
s(:call, s(:lit, 2), :a?, s(:call, nil, :b))),
|
1586
1421
|
s(:nil),
|
1587
1422
|
nil))
|
1588
1423
|
|
@@ -1593,34 +1428,33 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1593
1428
|
s(:if,
|
1594
1429
|
s(:flip3,
|
1595
1430
|
s(:call,
|
1596
|
-
s(:call, s(:call, nil, :i
|
1431
|
+
s(:call, s(:call, nil, :i),
|
1597
1432
|
:%,
|
1598
|
-
s(:
|
1433
|
+
s(:lit, 4)),
|
1599
1434
|
:==,
|
1600
|
-
s(:
|
1435
|
+
s(:lit, 0)),
|
1601
1436
|
s(:call,
|
1602
|
-
s(:call, s(:call, nil, :i
|
1437
|
+
s(:call, s(:call, nil, :i),
|
1603
1438
|
:%,
|
1604
|
-
s(:
|
1439
|
+
s(:lit, 3)),
|
1605
1440
|
:==,
|
1606
|
-
s(:
|
1607
|
-
s(:call, nil, :i
|
1441
|
+
s(:lit, 0))),
|
1442
|
+
s(:call, nil, :i),
|
1608
1443
|
s(:nil))))
|
1609
1444
|
|
1610
1445
|
add_tests("for",
|
1611
1446
|
"Ruby" => "for o in ary do\n puts(o)\nend",
|
1612
1447
|
"ParseTree" => s(:for,
|
1613
|
-
s(:call, nil, :ary
|
1448
|
+
s(:call, nil, :ary),
|
1614
1449
|
s(:lasgn, :o),
|
1615
|
-
s(:call, nil, :puts,
|
1616
|
-
s(:arglist, s(:lvar, :o)))))
|
1450
|
+
s(:call, nil, :puts, s(:lvar, :o))))
|
1617
1451
|
|
1618
1452
|
add_tests("for_no_body",
|
1619
1453
|
"Ruby" => "for i in (0..max) do\n # do nothing\nend",
|
1620
1454
|
"ParseTree" => s(:for,
|
1621
1455
|
s(:dot2,
|
1622
1456
|
s(:lit, 0),
|
1623
|
-
s(:call, nil, :max
|
1457
|
+
s(:call, nil, :max)),
|
1624
1458
|
s(:lasgn, :i)))
|
1625
1459
|
|
1626
1460
|
add_tests("gasgn",
|
@@ -1666,10 +1500,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1666
1500
|
"ParseTree" => s(:if,
|
1667
1501
|
s(:block,
|
1668
1502
|
s(:lasgn, :x, s(:lit, 5)),
|
1669
|
-
s(:call,
|
1670
|
-
s(:lvar, :x),
|
1671
|
-
:+,
|
1672
|
-
s(:arglist, s(:lit, 1)))),
|
1503
|
+
s(:call, s(:lvar, :x), :+, s(:lit, 1))),
|
1673
1504
|
s(:nil),
|
1674
1505
|
nil))
|
1675
1506
|
|
@@ -1678,9 +1509,9 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1678
1509
|
"ParseTree" => s(:if,
|
1679
1510
|
s(:lasgn, :x,
|
1680
1511
|
s(:call,
|
1681
|
-
s(:call, nil, :obj
|
1682
|
-
:x
|
1683
|
-
s(:call, s(:lvar, :x), :do_it
|
1512
|
+
s(:call, nil, :obj),
|
1513
|
+
:x)),
|
1514
|
+
s(:call, s(:lvar, :x), :do_it),
|
1684
1515
|
nil))
|
1685
1516
|
|
1686
1517
|
add_tests("if_nested",
|
@@ -1690,61 +1521,54 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1690
1521
|
|
1691
1522
|
add_tests("if_post",
|
1692
1523
|
"Ruby" => "a if b",
|
1693
|
-
"ParseTree" => s(:if, s(:call, nil, :b
|
1694
|
-
s(:call, nil, :a
|
1524
|
+
"ParseTree" => s(:if, s(:call, nil, :b),
|
1525
|
+
s(:call, nil, :a), nil))
|
1695
1526
|
|
1696
1527
|
add_tests("if_post_not",
|
1697
1528
|
"Ruby" => "a if not b",
|
1698
|
-
"ParseTree" => s(:if, s(:call, nil, :b
|
1699
|
-
s(:call, nil, :a
|
1529
|
+
"ParseTree" => s(:if, s(:call, nil, :b), nil,
|
1530
|
+
s(:call, nil, :a)),
|
1700
1531
|
"Ruby2Ruby" => "a unless b")
|
1701
1532
|
|
1702
1533
|
add_tests("if_pre",
|
1703
1534
|
"Ruby" => "if b then a end",
|
1704
|
-
"ParseTree" => s(:if, s(:call, nil, :b
|
1705
|
-
s(:call, nil, :a
|
1535
|
+
"ParseTree" => s(:if, s(:call, nil, :b),
|
1536
|
+
s(:call, nil, :a), nil),
|
1706
1537
|
"Ruby2Ruby" => "a if b")
|
1707
1538
|
|
1708
1539
|
add_tests("if_pre_not",
|
1709
1540
|
"Ruby" => "if not b then a end",
|
1710
|
-
"ParseTree" => s(:if, s(:call, nil, :b
|
1711
|
-
s(:call, nil, :a
|
1541
|
+
"ParseTree" => s(:if, s(:call, nil, :b), nil,
|
1542
|
+
s(:call, nil, :a)),
|
1712
1543
|
"Ruby2Ruby" => "a unless b")
|
1713
1544
|
|
1714
1545
|
add_tests("iter_call_arglist_space",
|
1715
1546
|
"Ruby" => "a (1) {|c|d}",
|
1716
1547
|
"ParseTree" => s(:iter,
|
1717
|
-
s(:call, nil, :a, s(:
|
1548
|
+
s(:call, nil, :a, s(:lit, 1)),
|
1718
1549
|
s(:lasgn, :c),
|
1719
|
-
s(:call, nil, :d
|
1550
|
+
s(:call, nil, :d)),
|
1720
1551
|
"Ruby2Ruby" => "a(1) { |c| d }")
|
1721
1552
|
|
1722
1553
|
add_tests("iter_dasgn_curr_dasgn_madness",
|
1723
1554
|
"Ruby" => "as.each { |a|\n b += a.b(false) }",
|
1724
1555
|
"ParseTree" => s(:iter,
|
1725
|
-
s(:call,
|
1726
|
-
s(:call, nil, :as, s(:arglist)),
|
1727
|
-
:each, s(:arglist)),
|
1556
|
+
s(:call, s(:call, nil, :as), :each),
|
1728
1557
|
s(:lasgn, :a),
|
1729
1558
|
s(:lasgn, :b,
|
1730
1559
|
s(:call,
|
1731
1560
|
s(:lvar, :b),
|
1732
1561
|
:+,
|
1733
|
-
s(:
|
1734
|
-
s(:call, s(:lvar, :a), :b,
|
1735
|
-
s(:arglist, s(:false))))))),
|
1562
|
+
s(:call, s(:lvar, :a), :b, s(:false))))),
|
1736
1563
|
"Ruby2Ruby" => "as.each { |a| b = (b + a.b(false)) }")
|
1737
1564
|
|
1738
1565
|
add_tests("iter_downto",
|
1739
1566
|
"Ruby" => "3.downto(1) { |n| puts(n.to_s) }",
|
1740
1567
|
"ParseTree" => s(:iter,
|
1741
|
-
s(:call, s(:lit, 3), :downto,
|
1742
|
-
s(:arglist, s(:lit, 1))),
|
1568
|
+
s(:call, s(:lit, 3), :downto, s(:lit, 1)),
|
1743
1569
|
s(:lasgn, :n),
|
1744
1570
|
s(:call, nil, :puts,
|
1745
|
-
s(:
|
1746
|
-
s(:call, s(:lvar, :n),
|
1747
|
-
:to_s, s(:arglist))))))
|
1571
|
+
s(:call, s(:lvar, :n), :to_s))))
|
1748
1572
|
|
1749
1573
|
add_tests("iter_each_lvar",
|
1750
1574
|
"Ruby" => "array = [1, 2, 3]\narray.each { |x| puts(x.to_s) }\n",
|
@@ -1753,12 +1577,10 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1753
1577
|
s(:array,
|
1754
1578
|
s(:lit, 1), s(:lit, 2), s(:lit, 3))),
|
1755
1579
|
s(:iter,
|
1756
|
-
s(:call, s(:lvar, :array), :each,
|
1757
|
-
s(:arglist)),
|
1580
|
+
s(:call, s(:lvar, :array), :each),
|
1758
1581
|
s(:lasgn, :x),
|
1759
1582
|
s(:call, nil, :puts,
|
1760
|
-
s(:
|
1761
|
-
:to_s, s(:arglist)))))))
|
1583
|
+
s(:call, s(:lvar, :x), :to_s)))))
|
1762
1584
|
|
1763
1585
|
add_tests("iter_each_nested",
|
1764
1586
|
"Ruby" => "array1 = [1, 2, 3]\narray2 = [4, 5, 6, 7]\narray1.each do |x|\n array2.each do |y|\n puts(x.to_s)\n puts(y.to_s)\n end\nend\n",
|
@@ -1772,108 +1594,98 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1772
1594
|
s(:lit, 6), s(:lit, 7))),
|
1773
1595
|
s(:iter,
|
1774
1596
|
s(:call,
|
1775
|
-
s(:lvar, :array1), :each
|
1597
|
+
s(:lvar, :array1), :each),
|
1776
1598
|
s(:lasgn, :x),
|
1777
1599
|
s(:iter,
|
1778
1600
|
s(:call,
|
1779
|
-
s(:lvar, :array2), :each
|
1601
|
+
s(:lvar, :array2), :each),
|
1780
1602
|
s(:lasgn, :y),
|
1781
1603
|
s(:block,
|
1782
1604
|
s(:call, nil, :puts,
|
1783
|
-
s(:
|
1784
|
-
s(:call, s(:lvar, :x),
|
1785
|
-
:to_s, s(:arglist)))),
|
1605
|
+
s(:call, s(:lvar, :x), :to_s)),
|
1786
1606
|
s(:call, nil, :puts,
|
1787
|
-
s(:
|
1788
|
-
s(:call, s(:lvar, :y),
|
1789
|
-
:to_s, s(:arglist)))))))))
|
1607
|
+
s(:call, s(:lvar, :y), :to_s)))))))
|
1790
1608
|
|
1791
1609
|
add_tests("iter_loop_empty",
|
1792
1610
|
"Ruby" => "loop { }",
|
1793
|
-
"ParseTree" => s(:iter, s(:call, nil, :loop
|
1611
|
+
"ParseTree" => s(:iter, s(:call, nil, :loop), nil))
|
1794
1612
|
|
1795
1613
|
add_tests("iter_masgn_2",
|
1796
1614
|
"Ruby" => "a { |b, c| p(c) }",
|
1797
1615
|
"ParseTree" => s(:iter,
|
1798
|
-
s(:call, nil, :a
|
1616
|
+
s(:call, nil, :a),
|
1799
1617
|
s(:masgn,
|
1800
1618
|
s(:array, s(:lasgn, :b), s(:lasgn, :c))),
|
1801
|
-
s(:call, nil, :p, s(:
|
1619
|
+
s(:call, nil, :p, s(:lvar, :c))))
|
1802
1620
|
|
1803
1621
|
add_tests("iter_masgn_args_splat",
|
1804
1622
|
"Ruby" => "a { |b, c, *d| p(c) }",
|
1805
1623
|
"ParseTree" => s(:iter,
|
1806
|
-
s(:call, nil, :a
|
1624
|
+
s(:call, nil, :a),
|
1807
1625
|
s(:masgn,
|
1808
1626
|
s(:array,
|
1809
1627
|
s(:lasgn, :b),
|
1810
1628
|
s(:lasgn, :c),
|
1811
1629
|
s(:splat, s(:lasgn, :d)))),
|
1812
|
-
s(:call, nil, :p, s(:
|
1630
|
+
s(:call, nil, :p, s(:lvar, :c))))
|
1813
1631
|
|
1814
1632
|
add_tests("iter_masgn_args_splat_no_name",
|
1815
1633
|
"Ruby" => "a { |b, c, *| p(c) }",
|
1816
1634
|
"ParseTree" => s(:iter,
|
1817
|
-
s(:call, nil, :a
|
1635
|
+
s(:call, nil, :a),
|
1818
1636
|
s(:masgn,
|
1819
1637
|
s(:array,
|
1820
1638
|
s(:lasgn, :b),
|
1821
1639
|
s(:lasgn, :c),
|
1822
1640
|
s(:splat))),
|
1823
|
-
s(:call, nil, :p, s(:
|
1641
|
+
s(:call, nil, :p, s(:lvar, :c))))
|
1824
1642
|
|
1825
1643
|
add_tests("iter_masgn_splat",
|
1826
1644
|
"Ruby" => "a { |*c| p(c) }",
|
1827
1645
|
"ParseTree" => s(:iter,
|
1828
|
-
s(:call, nil, :a
|
1646
|
+
s(:call, nil, :a),
|
1829
1647
|
s(:masgn, s(:array, s(:splat, s(:lasgn, :c)))),
|
1830
|
-
s(:call, nil, :p, s(:
|
1648
|
+
s(:call, nil, :p, s(:lvar, :c))))
|
1831
1649
|
|
1832
1650
|
add_tests("iter_masgn_splat_no_name",
|
1833
1651
|
"Ruby" => "a { |*| p(c) }",
|
1834
1652
|
"ParseTree" => s(:iter,
|
1835
|
-
s(:call, nil, :a
|
1653
|
+
s(:call, nil, :a),
|
1836
1654
|
s(:masgn, s(:array, s(:splat))),
|
1837
|
-
s(:call, nil, :p,
|
1838
|
-
s(:arglist, s(:call, nil, :c, s(:arglist))))))
|
1655
|
+
s(:call, nil, :p, s(:call, nil, :c))))
|
1839
1656
|
|
1840
1657
|
add_tests("iter_shadowed_var",
|
1841
1658
|
"Ruby" => "a do |x|\n b do |x|\n puts x\n end\nend",
|
1842
1659
|
"ParseTree" => s(:iter,
|
1843
|
-
s(:call, nil, :a
|
1660
|
+
s(:call, nil, :a),
|
1844
1661
|
s(:lasgn, :x),
|
1845
1662
|
s(:iter,
|
1846
|
-
s(:call, nil, :b
|
1663
|
+
s(:call, nil, :b),
|
1847
1664
|
s(:lasgn, :x),
|
1848
|
-
s(:call, nil, :puts,
|
1849
|
-
s(:arglist, s(:lvar, :x))))),
|
1665
|
+
s(:call, nil, :puts, s(:lvar, :x)))),
|
1850
1666
|
"Ruby2Ruby" => "a { |x| b { |x| puts(x) } }")
|
1851
1667
|
|
1852
1668
|
add_tests("iter_upto",
|
1853
1669
|
"Ruby" => "1.upto(3) { |n| puts(n.to_s) }",
|
1854
1670
|
"ParseTree" => s(:iter,
|
1855
|
-
s(:call, s(:lit, 1), :upto,
|
1856
|
-
s(:arglist, s(:lit, 3))),
|
1671
|
+
s(:call, s(:lit, 1), :upto, s(:lit, 3)),
|
1857
1672
|
s(:lasgn, :n),
|
1858
1673
|
s(:call, nil, :puts,
|
1859
|
-
s(:
|
1860
|
-
s(:call, s(:lvar, :n), :to_s,
|
1861
|
-
s(:arglist))))))
|
1674
|
+
s(:call, s(:lvar, :n), :to_s))))
|
1862
1675
|
|
1863
1676
|
add_tests("iter_while",
|
1864
1677
|
"Ruby" => "argl = 10\nwhile (argl >= 1) do\n puts(\"hello\")\n argl = (argl - 1)\nend\n",
|
1865
1678
|
"ParseTree" => s(:block,
|
1866
1679
|
s(:lasgn, :argl, s(:lit, 10)),
|
1867
1680
|
s(:while,
|
1868
|
-
s(:call, s(:lvar, :argl), :">=",
|
1869
|
-
s(:arglist, s(:lit, 1))),
|
1681
|
+
s(:call, s(:lvar, :argl), :">=", s(:lit, 1)),
|
1870
1682
|
s(:block,
|
1871
|
-
s(:call, nil, :puts,
|
1872
|
-
s(:arglist, s(:str, "hello"))),
|
1683
|
+
s(:call, nil, :puts, s(:str, "hello")),
|
1873
1684
|
s(:lasgn,
|
1874
1685
|
:argl,
|
1875
1686
|
s(:call, s(:lvar, :argl), :"-",
|
1876
|
-
s(:
|
1687
|
+
s(:lit, 1)))),
|
1688
|
+
true)))
|
1877
1689
|
|
1878
1690
|
add_tests("ivar",
|
1879
1691
|
"Ruby" => [Examples, :reader],
|
@@ -1891,8 +1703,8 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1891
1703
|
|
1892
1704
|
add_tests("lasgn_call",
|
1893
1705
|
"Ruby" => "c = (2 + 3)",
|
1894
|
-
"ParseTree" => s(:lasgn, :c,
|
1895
|
-
|
1706
|
+
"ParseTree" => s(:lasgn, :c,
|
1707
|
+
s(:call, s(:lit, 2), :+, s(:lit, 3))))
|
1896
1708
|
|
1897
1709
|
add_tests("lit_bool_false",
|
1898
1710
|
"Ruby" => "false",
|
@@ -1935,8 +1747,10 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1935
1747
|
|
1936
1748
|
add_tests("lit_regexp_i_wwtt",
|
1937
1749
|
"Ruby" => 'str.split(//i)',
|
1938
|
-
"ParseTree" => s(:call,
|
1939
|
-
s(:
|
1750
|
+
"ParseTree" => s(:call,
|
1751
|
+
s(:call, nil, :str),
|
1752
|
+
:split,
|
1753
|
+
s(:lit, //i)))
|
1940
1754
|
|
1941
1755
|
add_tests("lit_regexp_n",
|
1942
1756
|
"Ruby" => "/x/n", # HACK differs on 1.9 - this is easiest
|
@@ -1960,29 +1774,25 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
1960
1774
|
"Ruby" => "b = 42\ndef a\n c do\n begin\n do_stuff\n rescue RuntimeError => b\n puts(b)\n end\n end\nend\n",
|
1961
1775
|
"ParseTree" => s(:block,
|
1962
1776
|
s(:lasgn, :b, s(:lit, 42)),
|
1963
|
-
s(:defn, :a,
|
1964
|
-
s(:
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
s(:
|
1971
|
-
s(:
|
1972
|
-
s(:
|
1973
|
-
|
1974
|
-
|
1975
|
-
s(:lasgn, :b, s(:gvar, :$!))),
|
1976
|
-
s(:call, nil, :puts,
|
1977
|
-
s(:arglist,
|
1978
|
-
s(:lvar, :b)))))))))))
|
1777
|
+
s(:defn, :a, s(:args),
|
1778
|
+
s(:iter,
|
1779
|
+
s(:call, nil, :c),
|
1780
|
+
nil,
|
1781
|
+
s(:rescue,
|
1782
|
+
s(:call, nil, :do_stuff),
|
1783
|
+
s(:resbody,
|
1784
|
+
s(:array,
|
1785
|
+
s(:const, :RuntimeError),
|
1786
|
+
s(:lasgn, :b, s(:gvar, :$!))),
|
1787
|
+
s(:call, nil, :puts,
|
1788
|
+
s(:lvar, :b))))))))
|
1979
1789
|
|
1980
1790
|
add_tests("masgn",
|
1981
1791
|
"Ruby" => "a, b = c, d",
|
1982
1792
|
"ParseTree" => s(:masgn,
|
1983
1793
|
s(:array, s(:lasgn, :a), s(:lasgn, :b)),
|
1984
|
-
s(:array, s(:call, nil, :c
|
1985
|
-
s(:call, nil, :d
|
1794
|
+
s(:array, s(:call, nil, :c),
|
1795
|
+
s(:call, nil, :d))))
|
1986
1796
|
|
1987
1797
|
add_tests("masgn_argscat",
|
1988
1798
|
"Ruby" => "a, b, *c = 1, 2, *[3, 4]",
|
@@ -2002,25 +1812,25 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2002
1812
|
s(:array,
|
2003
1813
|
s(:lasgn, :a),
|
2004
1814
|
s(:attrasgn,
|
2005
|
-
s(:call, nil, :b
|
2006
|
-
:c
|
1815
|
+
s(:call, nil, :b),
|
1816
|
+
:c=)),
|
2007
1817
|
s(:array,
|
2008
|
-
s(:call, nil, :d
|
2009
|
-
s(:call, nil, :e
|
1818
|
+
s(:call, nil, :d),
|
1819
|
+
s(:call, nil, :e))))
|
2010
1820
|
|
2011
1821
|
add_tests("masgn_attrasgn_array_rhs",
|
2012
1822
|
"Ruby" => "a.b, a.c, _ = q",
|
2013
1823
|
"ParseTree" => s(:masgn,
|
2014
1824
|
s(:array,
|
2015
1825
|
s(:attrasgn,
|
2016
|
-
s(:call, nil, :a
|
2017
|
-
:b
|
1826
|
+
s(:call, nil, :a),
|
1827
|
+
:b=),
|
2018
1828
|
s(:attrasgn,
|
2019
|
-
s(:call, nil, :a
|
2020
|
-
:c
|
1829
|
+
s(:call, nil, :a),
|
1830
|
+
:c=),
|
2021
1831
|
s(:lasgn, :_)),
|
2022
1832
|
s(:to_ary,
|
2023
|
-
s(:call, nil, :q
|
1833
|
+
s(:call, nil, :q))))
|
2024
1834
|
|
2025
1835
|
add_tests("masgn_attrasgn_idx",
|
2026
1836
|
"Ruby" => "a, i, j = [], 1, 2\na[i], a[j] = a[j], a[i]\n",
|
@@ -2032,15 +1842,15 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2032
1842
|
s(:array, s(:array), s(:lit, 1), s(:lit, 2))),
|
2033
1843
|
s(:masgn,
|
2034
1844
|
s(:array,
|
2035
|
-
s(:attrasgn,
|
2036
|
-
s(:
|
2037
|
-
s(:attrasgn,
|
2038
|
-
s(:
|
1845
|
+
s(:attrasgn,
|
1846
|
+
s(:lvar, :a), :[]=, s(:lvar, :i)),
|
1847
|
+
s(:attrasgn,
|
1848
|
+
s(:lvar, :a), :[]=, s(:lvar, :j))),
|
2039
1849
|
s(:array,
|
2040
|
-
s(:call,
|
2041
|
-
s(:
|
2042
|
-
s(:call,
|
2043
|
-
s(:
|
1850
|
+
s(:call,
|
1851
|
+
s(:lvar, :a), :[], s(:lvar, :j)),
|
1852
|
+
s(:call,
|
1853
|
+
s(:lvar, :a), :[], s(:lvar, :i))))))
|
2044
1854
|
|
2045
1855
|
add_tests("masgn_cdecl",
|
2046
1856
|
"Ruby" => "A, B, C = 1, 2, 3",
|
@@ -2055,8 +1865,8 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2055
1865
|
"ParseTree" => s(:masgn,
|
2056
1866
|
s(:array, s(:lasgn, :a), s(:iasgn, :"@b")),
|
2057
1867
|
s(:array,
|
2058
|
-
s(:call, nil, :c
|
2059
|
-
s(:call, nil, :d
|
1868
|
+
s(:call, nil, :c),
|
1869
|
+
s(:call, nil, :d))))
|
2060
1870
|
|
2061
1871
|
add_tests("masgn_masgn",
|
2062
1872
|
"Ruby" => "a, (b, c) = [1, [2, 3]]",
|
@@ -2082,10 +1892,10 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2082
1892
|
s(:lasgn, :b),
|
2083
1893
|
s(:splat, s(:lasgn, :c))),
|
2084
1894
|
s(:array,
|
2085
|
-
s(:call, nil, :d
|
2086
|
-
s(:call, nil, :e
|
2087
|
-
s(:call, nil, :f
|
2088
|
-
s(:call, nil, :g
|
1895
|
+
s(:call, nil, :d),
|
1896
|
+
s(:call, nil, :e),
|
1897
|
+
s(:call, nil, :f),
|
1898
|
+
s(:call, nil, :g))))
|
2089
1899
|
|
2090
1900
|
add_tests("masgn_splat_rhs_1",
|
2091
1901
|
"Ruby" => "a, b = *c",
|
@@ -2093,7 +1903,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2093
1903
|
s(:array,
|
2094
1904
|
s(:lasgn, :a),
|
2095
1905
|
s(:lasgn, :b)),
|
2096
|
-
s(:splat, s(:call, nil, :c
|
1906
|
+
s(:splat, s(:call, nil, :c))))
|
2097
1907
|
|
2098
1908
|
add_tests("masgn_splat_rhs_n",
|
2099
1909
|
"Ruby" => "a, b = c, d, *e",
|
@@ -2102,9 +1912,9 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2102
1912
|
s(:lasgn, :a),
|
2103
1913
|
s(:lasgn, :b)),
|
2104
1914
|
s(:array,
|
2105
|
-
s(:call, nil, :c
|
2106
|
-
s(:call, nil, :d
|
2107
|
-
s(:splat, s(:call, nil, :e
|
1915
|
+
s(:call, nil, :c),
|
1916
|
+
s(:call, nil, :d),
|
1917
|
+
s(:splat, s(:call, nil, :e)))))
|
2108
1918
|
|
2109
1919
|
add_tests("masgn_splat_no_name_to_ary",
|
2110
1920
|
"Ruby" => "a, b, * = c",
|
@@ -2113,13 +1923,13 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2113
1923
|
s(:lasgn, :a),
|
2114
1924
|
s(:lasgn, :b),
|
2115
1925
|
s(:splat)),
|
2116
|
-
s(:to_ary, s(:call, nil, :c
|
1926
|
+
s(:to_ary, s(:call, nil, :c))))
|
2117
1927
|
|
2118
1928
|
add_tests("masgn_splat_no_name_trailing",
|
2119
1929
|
"Ruby" => "a, b, = c",
|
2120
1930
|
"ParseTree" => s(:masgn,
|
2121
1931
|
s(:array, s(:lasgn, :a), s(:lasgn, :b)),
|
2122
|
-
s(:to_ary, s(:call, nil, :c
|
1932
|
+
s(:to_ary, s(:call, nil, :c))),
|
2123
1933
|
"Ruby2Ruby" => "a, b = c") # TODO: check this is right
|
2124
1934
|
|
2125
1935
|
add_tests("masgn_splat_to_ary",
|
@@ -2129,7 +1939,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2129
1939
|
s(:lasgn, :a),
|
2130
1940
|
s(:lasgn, :b),
|
2131
1941
|
s(:splat, s(:lasgn, :c))),
|
2132
|
-
s(:to_ary, s(:call, nil, :d
|
1942
|
+
s(:to_ary, s(:call, nil, :d))))
|
2133
1943
|
|
2134
1944
|
add_tests("masgn_splat_to_ary2",
|
2135
1945
|
"Ruby" => "a, b, *c = d.e(\"f\")",
|
@@ -2140,9 +1950,9 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2140
1950
|
s(:splat, s(:lasgn, :c))),
|
2141
1951
|
s(:to_ary,
|
2142
1952
|
s(:call,
|
2143
|
-
s(:call, nil, :d
|
1953
|
+
s(:call, nil, :d),
|
2144
1954
|
:e,
|
2145
|
-
s(:
|
1955
|
+
s(:str, 'f')))))
|
2146
1956
|
|
2147
1957
|
add_tests("match",
|
2148
1958
|
"Ruby" => "1 if /x/",
|
@@ -2159,33 +1969,29 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2159
1969
|
add_tests("module",
|
2160
1970
|
"Ruby" => "module X\n def y\n # do nothing\n end\nend",
|
2161
1971
|
"ParseTree" => s(:module, :X,
|
2162
|
-
s(:
|
2163
|
-
s(:defn, :y,
|
2164
|
-
s(:args),
|
2165
|
-
s(:scope, s(:block, s(:nil)))))))
|
1972
|
+
s(:defn, :y, s(:args), s(:nil))))
|
2166
1973
|
|
2167
1974
|
add_tests("module_scoped",
|
2168
1975
|
"Ruby" => "module X::Y\n c\nend",
|
2169
1976
|
"ParseTree" => s(:module, s(:colon2, s(:const, :X), :Y),
|
2170
|
-
s(:
|
1977
|
+
s(:call, nil, :c)))
|
2171
1978
|
|
2172
1979
|
add_tests("module_scoped3",
|
2173
1980
|
"Ruby" => "module ::Y\n c\nend",
|
2174
|
-
"ParseTree" => s(:module,
|
2175
|
-
s(:
|
2176
|
-
s(:scope, s(:call, nil, :c, s(:arglist)))))
|
1981
|
+
"ParseTree" => s(:module, s(:colon3, :Y),
|
1982
|
+
s(:call, nil, :c)))
|
2177
1983
|
|
2178
1984
|
add_tests("next",
|
2179
1985
|
"Ruby" => "loop { next if false }",
|
2180
1986
|
"ParseTree" => s(:iter,
|
2181
|
-
s(:call, nil, :loop
|
1987
|
+
s(:call, nil, :loop),
|
2182
1988
|
nil,
|
2183
1989
|
s(:if, s(:false), s(:next), nil)))
|
2184
1990
|
|
2185
1991
|
add_tests("next_arg",
|
2186
1992
|
"Ruby" => "loop { next 42 if false }",
|
2187
1993
|
"ParseTree" => s(:iter,
|
2188
|
-
s(:call, nil, :loop
|
1994
|
+
s(:call, nil, :loop),
|
2189
1995
|
nil,
|
2190
1996
|
s(:if, s(:false), s(:next, s(:lit, 42)), nil)))
|
2191
1997
|
|
@@ -2223,11 +2029,12 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2223
2029
|
"Ruby" => "s = Struct.new(:var)\nc = s.new(nil)\nc.var ||= 20\nc.var &&= 21\nc.var += 22\nc.d.e.f ||= 42\n",
|
2224
2030
|
"ParseTree" => s(:block,
|
2225
2031
|
s(:lasgn, :s,
|
2226
|
-
s(:call,
|
2227
|
-
|
2032
|
+
s(:call,
|
2033
|
+
s(:const, :Struct),
|
2034
|
+
:new,
|
2035
|
+
s(:lit, :var))),
|
2228
2036
|
s(:lasgn, :c,
|
2229
|
-
s(:call, s(:lvar, :s),
|
2230
|
-
:new, s(:arglist, s(:nil)))),
|
2037
|
+
s(:call, s(:lvar, :s), :new, s(:nil))),
|
2231
2038
|
s(:op_asgn2, s(:lvar, :c),
|
2232
2039
|
:var=, :"||", s(:lit, 20)),
|
2233
2040
|
s(:op_asgn2, s(:lvar, :c),
|
@@ -2236,14 +2043,14 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2236
2043
|
:var=, :+, s(:lit, 22)),
|
2237
2044
|
s(:op_asgn2,
|
2238
2045
|
s(:call,
|
2239
|
-
s(:call, s(:lvar, :c), :d
|
2240
|
-
:e
|
2046
|
+
s(:call, s(:lvar, :c), :d),
|
2047
|
+
:e),
|
2241
2048
|
:f=, :"||", s(:lit, 42))))
|
2242
2049
|
|
2243
2050
|
add_tests("op_asgn2_self",
|
2244
2051
|
"Ruby" => "self.Bag ||= Bag.new",
|
2245
2052
|
"ParseTree" => s(:op_asgn2, s(:self), :"Bag=", :"||",
|
2246
|
-
s(:call, s(:const, :Bag), :new
|
2053
|
+
s(:call, s(:const, :Bag), :new)))
|
2247
2054
|
|
2248
2055
|
add_tests("op_asgn_and",
|
2249
2056
|
"Ruby" => "a = 0\na &&= 2\n",
|
@@ -2260,13 +2067,10 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2260
2067
|
:@fetcher,
|
2261
2068
|
s(:call, nil,
|
2262
2069
|
:new,
|
2263
|
-
s(:
|
2264
|
-
s(:call,
|
2265
|
-
|
2266
|
-
|
2267
|
-
s(:arglist)),
|
2268
|
-
:[],
|
2269
|
-
s(:arglist, s(:lit, :http_proxy))))))))
|
2070
|
+
s(:call,
|
2071
|
+
s(:call, s(:const, :Gem), :configuration),
|
2072
|
+
:[],
|
2073
|
+
s(:lit, :http_proxy))))))
|
2270
2074
|
|
2271
2075
|
add_tests("op_asgn_or",
|
2272
2076
|
"Ruby" => "a = 0\na ||= 1\n",
|
@@ -2281,13 +2085,13 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2281
2085
|
s(:lvar, :a),
|
2282
2086
|
s(:lasgn, :a,
|
2283
2087
|
s(:rescue,
|
2284
|
-
s(:call, nil, :b
|
2088
|
+
s(:call, nil, :b),
|
2285
2089
|
s(:resbody, s(:array),
|
2286
|
-
s(:call, nil, :c
|
2090
|
+
s(:call, nil, :c))))),
|
2287
2091
|
"Ruby2Ruby" => "a ||= b rescue c")
|
2288
2092
|
|
2289
2093
|
add_tests("op_asgn_or_ivar",
|
2290
|
-
"Ruby" => "@v ||= {
|
2094
|
+
"Ruby" => "@v ||= {}",
|
2291
2095
|
"ParseTree" => s(:op_asgn_or,
|
2292
2096
|
s(:ivar, :@v),
|
2293
2097
|
s(:iasgn, :@v, s(:hash))))
|
@@ -2299,39 +2103,36 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2299
2103
|
s(:iasgn,
|
2300
2104
|
:@fetcher,
|
2301
2105
|
s(:call, nil, :new,
|
2302
|
-
s(:
|
2303
|
-
s(:call,
|
2304
|
-
|
2305
|
-
|
2306
|
-
s(:arglist)),
|
2307
|
-
:[],
|
2308
|
-
s(:arglist, s(:lit, :http_proxy))))))))
|
2106
|
+
s(:call,
|
2107
|
+
s(:call, s(:const, :Gem), :configuration),
|
2108
|
+
:[],
|
2109
|
+
s(:lit, :http_proxy))))))
|
2309
2110
|
|
2310
2111
|
add_tests("or",
|
2311
2112
|
"Ruby" => "(a or b)",
|
2312
2113
|
"ParseTree" => s(:or,
|
2313
|
-
s(:call, nil, :a
|
2314
|
-
s(:call, nil, :b
|
2114
|
+
s(:call, nil, :a),
|
2115
|
+
s(:call, nil, :b)))
|
2315
2116
|
|
2316
2117
|
add_tests("or_big",
|
2317
2118
|
"Ruby" => "((a or b) or (c and d))",
|
2318
2119
|
"ParseTree" => s(:or,
|
2319
2120
|
s(:or,
|
2320
|
-
s(:call, nil, :a
|
2321
|
-
s(:call, nil, :b
|
2121
|
+
s(:call, nil, :a),
|
2122
|
+
s(:call, nil, :b)),
|
2322
2123
|
s(:and,
|
2323
|
-
s(:call, nil, :c
|
2324
|
-
s(:call, nil, :d
|
2124
|
+
s(:call, nil, :c),
|
2125
|
+
s(:call, nil, :d))))
|
2325
2126
|
|
2326
2127
|
add_tests("or_big2",
|
2327
2128
|
"Ruby" => "((a || b) || (c && d))",
|
2328
2129
|
"ParseTree" => s(:or,
|
2329
2130
|
s(:or,
|
2330
|
-
s(:call, nil, :a
|
2331
|
-
s(:call, nil, :b
|
2131
|
+
s(:call, nil, :a),
|
2132
|
+
s(:call, nil, :b)),
|
2332
2133
|
s(:and,
|
2333
|
-
s(:call, nil, :c
|
2334
|
-
s(:call, nil, :d
|
2134
|
+
s(:call, nil, :c),
|
2135
|
+
s(:call, nil, :d))),
|
2335
2136
|
"Ruby2Ruby" => "((a or b) or (c and d))")
|
2336
2137
|
|
2337
2138
|
add_tests("parse_floats_as_args",
|
@@ -2341,10 +2142,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2341
2142
|
s(:block,
|
2342
2143
|
s(:lasgn, :a, s(:lit, 0.0)),
|
2343
2144
|
s(:lasgn, :b, s(:lit, 0.0)))),
|
2344
|
-
s(:
|
2345
|
-
s(:block,
|
2346
|
-
s(:call, s(:lvar, :a), :+,
|
2347
|
-
s(:arglist, s(:lvar, :b)))))),
|
2145
|
+
s(:call, s(:lvar, :a), :+, s(:lvar, :b))),
|
2348
2146
|
"Ruby2Ruby" => "def x(a = 0.0, b = 0.0)\n (a + b)\nend")
|
2349
2147
|
|
2350
2148
|
add_tests("postexe",
|
@@ -2354,44 +2152,38 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2354
2152
|
add_tests("proc_args_0",
|
2355
2153
|
"Ruby" => "proc { || (x + 1) }",
|
2356
2154
|
"ParseTree" => s(:iter,
|
2357
|
-
s(:call, nil, :proc
|
2155
|
+
s(:call, nil, :proc),
|
2358
2156
|
0,
|
2359
|
-
s(:call,
|
2360
|
-
s(:call, nil, :x, s(:arglist)),
|
2361
|
-
:+,
|
2362
|
-
s(:arglist, s(:lit, 1)))))
|
2157
|
+
s(:call, s(:call, nil, :x), :+, s(:lit, 1))))
|
2363
2158
|
|
2364
2159
|
add_tests("proc_args_1",
|
2365
2160
|
"Ruby" => "proc { |x| (x + 1) }",
|
2366
2161
|
"ParseTree" => s(:iter,
|
2367
|
-
s(:call, nil, :proc
|
2162
|
+
s(:call, nil, :proc),
|
2368
2163
|
s(:lasgn, :x),
|
2369
|
-
s(:call, s(:lvar, :x), :+,
|
2370
|
-
s(:arglist, s(:lit, 1)))))
|
2164
|
+
s(:call, s(:lvar, :x), :+, s(:lit, 1))))
|
2371
2165
|
|
2372
2166
|
add_tests("proc_args_2",
|
2373
2167
|
"Ruby" => "proc { |x, y| (x + y) }",
|
2374
2168
|
"ParseTree" => s(:iter,
|
2375
|
-
s(:call, nil, :proc
|
2169
|
+
s(:call, nil, :proc),
|
2376
2170
|
s(:masgn,
|
2377
2171
|
s(:array,
|
2378
2172
|
s(:lasgn, :x),
|
2379
2173
|
s(:lasgn, :y))),
|
2380
|
-
s(:call, s(:lvar, :x), :+,
|
2381
|
-
s(:arglist, s(:lvar, :y)))))
|
2174
|
+
s(:call, s(:lvar, :x), :+, s(:lvar, :y))))
|
2382
2175
|
|
2383
2176
|
add_tests("proc_args_no",
|
2384
2177
|
"Ruby" => "proc { (x + 1) }",
|
2385
2178
|
"ParseTree" => s(:iter,
|
2386
|
-
s(:call, nil, :proc
|
2179
|
+
s(:call, nil, :proc),
|
2387
2180
|
nil,
|
2388
|
-
s(:call, s(:call, nil, :x, s(:
|
2389
|
-
:+, s(:arglist, s(:lit, 1)))))
|
2181
|
+
s(:call, s(:call, nil, :x), :+, s(:lit, 1))))
|
2390
2182
|
|
2391
2183
|
add_tests("redo",
|
2392
2184
|
"Ruby" => "loop { redo if false }",
|
2393
2185
|
"ParseTree" => s(:iter,
|
2394
|
-
s(:call, nil, :loop
|
2186
|
+
s(:call, nil, :loop),
|
2395
2187
|
nil,
|
2396
2188
|
s(:if, s(:false), s(:redo), nil)))
|
2397
2189
|
|
@@ -2400,50 +2192,48 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2400
2192
|
add_tests("rescue",
|
2401
2193
|
"Ruby" => "blah rescue nil",
|
2402
2194
|
"ParseTree" => s(:rescue,
|
2403
|
-
s(:call, nil, :blah
|
2195
|
+
s(:call, nil, :blah),
|
2404
2196
|
s(:resbody, s(:array), s(:nil))))
|
2405
2197
|
|
2406
2198
|
add_tests("rescue_block_body",
|
2407
2199
|
"Ruby" => "begin\n a\nrescue => e\n c\n d\nend",
|
2408
2200
|
"ParseTree" => s(:rescue,
|
2409
|
-
s(:call, nil, :a
|
2201
|
+
s(:call, nil, :a),
|
2410
2202
|
s(:resbody,
|
2411
2203
|
s(:array, s(:lasgn, :e, s(:gvar, :$!))),
|
2412
|
-
s(:
|
2413
|
-
|
2414
|
-
s(:call, nil, :d, s(:arglist))))))
|
2204
|
+
s(:call, nil, :c),
|
2205
|
+
s(:call, nil, :d))))
|
2415
2206
|
|
2416
2207
|
add_tests("rescue_block_body_3",
|
2417
2208
|
"Ruby" => "begin\n a\nrescue A\n b\nrescue B\n c\nrescue C\n d\nend",
|
2418
2209
|
"ParseTree" => s(:rescue,
|
2419
|
-
s(:call, nil, :a
|
2210
|
+
s(:call, nil, :a),
|
2420
2211
|
s(:resbody, s(:array, s(:const, :A)),
|
2421
|
-
s(:call, nil, :b
|
2212
|
+
s(:call, nil, :b)),
|
2422
2213
|
s(:resbody, s(:array, s(:const, :B)),
|
2423
|
-
s(:call, nil, :c
|
2214
|
+
s(:call, nil, :c)),
|
2424
2215
|
s(:resbody, s(:array, s(:const, :C)),
|
2425
|
-
s(:call, nil, :d
|
2216
|
+
s(:call, nil, :d))))
|
2426
2217
|
|
2427
2218
|
add_tests("rescue_block_body_ivar",
|
2428
2219
|
"Ruby" => "begin\n a\nrescue => @e\n c\n d\nend",
|
2429
2220
|
"ParseTree" => s(:rescue,
|
2430
|
-
s(:call, nil, :a
|
2221
|
+
s(:call, nil, :a),
|
2431
2222
|
s(:resbody,
|
2432
2223
|
s(:array, s(:iasgn, :@e, s(:gvar, :$!))),
|
2433
|
-
s(:
|
2434
|
-
|
2435
|
-
s(:call, nil, :d, s(:arglist))))))
|
2224
|
+
s(:call, nil, :c),
|
2225
|
+
s(:call, nil, :d))))
|
2436
2226
|
|
2437
2227
|
add_tests("rescue_block_nada",
|
2438
2228
|
"Ruby" => "begin\n blah\nrescue\n # do nothing\nend",
|
2439
2229
|
"ParseTree" => s(:rescue,
|
2440
|
-
s(:call, nil, :blah
|
2230
|
+
s(:call, nil, :blah),
|
2441
2231
|
s(:resbody, s(:array), nil)))
|
2442
2232
|
|
2443
2233
|
add_tests("rescue_exceptions",
|
2444
2234
|
"Ruby" => "begin\n blah\nrescue RuntimeError => r\n # do nothing\nend",
|
2445
2235
|
"ParseTree" => s(:rescue,
|
2446
|
-
s(:call, nil, :blah
|
2236
|
+
s(:call, nil, :blah),
|
2447
2237
|
s(:resbody,
|
2448
2238
|
s(:array,
|
2449
2239
|
s(:const, :RuntimeError),
|
@@ -2508,26 +2298,20 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2508
2298
|
|
2509
2299
|
add_tests("sclass",
|
2510
2300
|
"Ruby" => "class << self\n 42\nend",
|
2511
|
-
"ParseTree" => s(:sclass, s(:self), s(:
|
2301
|
+
"ParseTree" => s(:sclass, s(:self), s(:lit, 42)))
|
2512
2302
|
|
2513
2303
|
add_tests("sclass_trailing_class",
|
2514
|
-
"Ruby" => "class A\n class << self\n a\n end\n class B\n end\nend",
|
2304
|
+
"Ruby" => "class A\n class << self\n a\n end\n \n class B\n end\nend",
|
2515
2305
|
"ParseTree" => s(:class, :A, nil,
|
2516
|
-
s(:
|
2517
|
-
s(:
|
2518
|
-
|
2519
|
-
s(:scope,
|
2520
|
-
s(:call, nil, :a, s(:arglist)))),
|
2521
|
-
s(:class, :B, nil, s(:scope))))))
|
2306
|
+
s(:sclass, s(:self),
|
2307
|
+
s(:call, nil, :a)),
|
2308
|
+
s(:class, :B, nil)))
|
2522
2309
|
|
2523
2310
|
add_tests("splat",
|
2524
2311
|
"Ruby" => "def x(*b)\n a(*b)\nend",
|
2525
2312
|
"ParseTree" => s(:defn, :x,
|
2526
2313
|
s(:args, :"*b"),
|
2527
|
-
s(:
|
2528
|
-
s(:block,
|
2529
|
-
s(:call, nil, :a,
|
2530
|
-
s(:arglist, s(:splat, s(:lvar, :b))))))))
|
2314
|
+
s(:call, nil, :a, s(:splat, s(:lvar, :b)))))
|
2531
2315
|
|
2532
2316
|
add_tests("splat_array",
|
2533
2317
|
"Ruby" => "[*[1]]",
|
@@ -2543,14 +2327,15 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2543
2327
|
|
2544
2328
|
add_tests("splat_fcall",
|
2545
2329
|
"Ruby" => "meth(*[1])",
|
2546
|
-
"ParseTree" => s(:call,
|
2547
|
-
|
2330
|
+
"ParseTree" => s(:call,
|
2331
|
+
nil,
|
2332
|
+
:meth,
|
2333
|
+
s(:splat, s(:array, s(:lit, 1)))))
|
2548
2334
|
|
2549
2335
|
add_tests("splat_fcall_array",
|
2550
2336
|
"Ruby" => "meth([*[1]])",
|
2551
2337
|
"ParseTree" => s(:call, nil, :meth,
|
2552
|
-
|
2553
|
-
s(:array, s(:splat, s(:array, s(:lit, 1)))))))
|
2338
|
+
s(:array, s(:splat, s(:array, s(:lit, 1))))))
|
2554
2339
|
|
2555
2340
|
add_tests("splat_lasgn",
|
2556
2341
|
"Ruby" => "x = *[1]",
|
@@ -2624,7 +2409,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2624
2409
|
add_tests("str_heredoc_call",
|
2625
2410
|
"Ruby" => "<<'EOM'.strip\n blah\nblah\nEOM",
|
2626
2411
|
"ParseTree" => s(:call, s(:str, " blah\nblah\n"),
|
2627
|
-
:strip
|
2412
|
+
:strip),
|
2628
2413
|
"Ruby2Ruby" => "\" blah\\nblah\\n\".strip")
|
2629
2414
|
|
2630
2415
|
add_tests("str_heredoc_double",
|
@@ -2633,13 +2418,13 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2633
2418
|
s(:call,
|
2634
2419
|
s(:lvar, :a),
|
2635
2420
|
:+,
|
2636
|
-
s(:
|
2421
|
+
s(:call,
|
2637
2422
|
s(:call,
|
2638
|
-
s(:
|
2639
|
-
s(:arglist,
|
2640
|
-
s(:call, nil, :b, s(:arglist)))),
|
2423
|
+
s(:str, " first\n"),
|
2641
2424
|
:+,
|
2642
|
-
s(:
|
2425
|
+
s(:call, nil, :b)),
|
2426
|
+
:+,
|
2427
|
+
s(:str, " second\n")))),
|
2643
2428
|
"Ruby2Ruby" => "a = (a + ((\" first\\n\" + b) + \" second\\n\"))")
|
2644
2429
|
|
2645
2430
|
add_tests("str_heredoc_empty", # yes... tarded
|
@@ -2661,19 +2446,18 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2661
2446
|
"Ruby" => "a.b do |c, d|\n unless e.f(c) then\n g = false\n d.h { |x, i| g = true }\n end\nend",
|
2662
2447
|
"ParseTree" => s(:iter,
|
2663
2448
|
s(:call,
|
2664
|
-
s(:call, nil, :a
|
2665
|
-
:b
|
2449
|
+
s(:call, nil, :a),
|
2450
|
+
:b),
|
2666
2451
|
s(:masgn, s(:array,
|
2667
2452
|
s(:lasgn, :c),
|
2668
2453
|
s(:lasgn, :d))),
|
2669
2454
|
s(:if,
|
2670
|
-
s(:call, s(:call, nil, :e, s(:
|
2671
|
-
s(:arglist, s(:lvar, :c))),
|
2455
|
+
s(:call, s(:call, nil, :e), :f, s(:lvar, :c)),
|
2672
2456
|
nil,
|
2673
2457
|
s(:block,
|
2674
2458
|
s(:lasgn, :g, s(:false)),
|
2675
2459
|
s(:iter,
|
2676
|
-
s(:call, s(:lvar, :d), :h
|
2460
|
+
s(:call, s(:lvar, :d), :h),
|
2677
2461
|
s(:masgn, s(:array,
|
2678
2462
|
s(:lasgn, :x),
|
2679
2463
|
s(:lasgn, :i))),
|
@@ -2681,12 +2465,11 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2681
2465
|
|
2682
2466
|
add_tests("structure_remove_begin_1",
|
2683
2467
|
"Ruby" => "a << begin\n b\n rescue\n c\n end",
|
2684
|
-
"ParseTree" => s(:call, s(:call, nil, :a
|
2685
|
-
s(:
|
2686
|
-
s(:
|
2687
|
-
|
2688
|
-
s(:
|
2689
|
-
s(:call, nil, :c, s(:arglist)))))),
|
2468
|
+
"ParseTree" => s(:call, s(:call, nil, :a), :<<,
|
2469
|
+
s(:rescue,
|
2470
|
+
s(:call, nil, :b),
|
2471
|
+
s(:resbody, s(:array),
|
2472
|
+
s(:call, nil, :c)))),
|
2690
2473
|
"Ruby2Ruby" => "(a << b rescue c)")
|
2691
2474
|
|
2692
2475
|
add_tests("structure_remove_begin_2",
|
@@ -2694,8 +2477,8 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2694
2477
|
"ParseTree" => s(:block,
|
2695
2478
|
s(:lasgn,
|
2696
2479
|
:a,
|
2697
|
-
s(:if, s(:call, nil, :c
|
2698
|
-
s(:rescue, s(:call, nil, :b
|
2480
|
+
s(:if, s(:call, nil, :c),
|
2481
|
+
s(:rescue, s(:call, nil, :b),
|
2699
2482
|
s(:resbody,
|
2700
2483
|
s(:array), s(:nil))),
|
2701
2484
|
nil)),
|
@@ -2704,65 +2487,52 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2704
2487
|
|
2705
2488
|
add_tests("structure_unused_literal_wwtt",
|
2706
2489
|
"Ruby" => "\"prevent the above from infecting rdoc\"\n\nmodule Graffle\nend",
|
2707
|
-
"ParseTree" => s(:module, :Graffle
|
2490
|
+
"ParseTree" => s(:module, :Graffle),
|
2708
2491
|
"Ruby2Ruby" => "module Graffle\nend")
|
2709
2492
|
|
2710
2493
|
add_tests("super_0",
|
2711
2494
|
"Ruby" => "def x\n super()\nend",
|
2712
|
-
"ParseTree" => s(:defn, :x,
|
2713
|
-
s(:args),
|
2714
|
-
s(:scope, s(:block, s(:super)))))
|
2495
|
+
"ParseTree" => s(:defn, :x, s(:args), s(:super)))
|
2715
2496
|
|
2716
2497
|
add_tests("super_1",
|
2717
2498
|
"Ruby" => "def x\n super(4)\nend",
|
2718
|
-
"ParseTree" => s(:defn, :x,
|
2719
|
-
s(:
|
2720
|
-
s(:scope,
|
2721
|
-
s(:block,
|
2722
|
-
s(:super, s(:lit, 4))))))
|
2499
|
+
"ParseTree" => s(:defn, :x, s(:args),
|
2500
|
+
s(:super, s(:lit, 4))))
|
2723
2501
|
|
2724
2502
|
add_tests("super_1_array",
|
2725
2503
|
"Ruby" => "def x\n super([24, 42])\nend",
|
2726
|
-
"ParseTree" => s(:defn, :x,
|
2727
|
-
s(:
|
2728
|
-
|
2729
|
-
s(:block,
|
2730
|
-
s(:super, s(:array,
|
2731
|
-
s(:lit, 24),
|
2732
|
-
s(:lit, 42)))))))
|
2733
|
-
|
2504
|
+
"ParseTree" => s(:defn, :x, s(:args),
|
2505
|
+
s(:super, s(:array, s(:lit, 24), s(:lit, 42)))))
|
2506
|
+
|
2734
2507
|
add_tests("super_block_pass",
|
2735
2508
|
"Ruby" => "super(a, &b)",
|
2736
2509
|
"ParseTree" => s(:super,
|
2737
|
-
s(:call, nil, :a
|
2510
|
+
s(:call, nil, :a),
|
2738
2511
|
s(:block_pass,
|
2739
|
-
s(:call, nil, :b
|
2512
|
+
s(:call, nil, :b))))
|
2740
2513
|
|
2741
2514
|
add_tests("super_block_splat",
|
2742
2515
|
"Ruby" => "super(a, *b)",
|
2743
2516
|
"ParseTree" => s(:super,
|
2744
|
-
s(:call, nil, :a
|
2745
|
-
s(:splat, s(:call, nil, :b
|
2517
|
+
s(:call, nil, :a),
|
2518
|
+
s(:splat, s(:call, nil, :b))))
|
2746
2519
|
|
2747
2520
|
add_tests("super_n",
|
2748
2521
|
"Ruby" => "def x\n super(24, 42)\nend",
|
2749
|
-
"ParseTree" => s(:defn, :x,
|
2750
|
-
s(:
|
2751
|
-
s(:scope,
|
2752
|
-
s(:block,
|
2753
|
-
s(:super, s(:lit, 24), s(:lit, 42))))))
|
2522
|
+
"ParseTree" => s(:defn, :x, s(:args),
|
2523
|
+
s(:super, s(:lit, 24), s(:lit, 42))))
|
2754
2524
|
|
2755
2525
|
add_tests("svalue",
|
2756
2526
|
"Ruby" => "a = *b",
|
2757
2527
|
"ParseTree" => s(:lasgn, :a,
|
2758
2528
|
s(:svalue,
|
2759
|
-
s(:splat, s(:call, nil, :b
|
2529
|
+
s(:splat, s(:call, nil, :b)))))
|
2760
2530
|
|
2761
2531
|
add_tests("to_ary",
|
2762
2532
|
"Ruby" => "a, b = c",
|
2763
2533
|
"ParseTree" => s(:masgn,
|
2764
2534
|
s(:array, s(:lasgn, :a), s(:lasgn, :b)),
|
2765
|
-
s(:to_ary, s(:call, nil, :c
|
2535
|
+
s(:to_ary, s(:call, nil, :c))))
|
2766
2536
|
|
2767
2537
|
add_tests("true",
|
2768
2538
|
"Ruby" => "true",
|
@@ -2790,13 +2560,13 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2790
2560
|
add_tests("undef_block_1",
|
2791
2561
|
"Ruby" => "f1\nundef :x\n", # TODO: don't like the extra return
|
2792
2562
|
"ParseTree" => s(:block,
|
2793
|
-
s(:call, nil, :f1
|
2563
|
+
s(:call, nil, :f1),
|
2794
2564
|
s(:undef, s(:lit, :x))))
|
2795
2565
|
|
2796
2566
|
add_tests("undef_block_2",
|
2797
2567
|
"Ruby" => "f1\nundef :x, :y",
|
2798
2568
|
"ParseTree" => s(:block,
|
2799
|
-
s(:call, nil, :f1
|
2569
|
+
s(:call, nil, :f1),
|
2800
2570
|
s(:block,
|
2801
2571
|
s(:undef, s(:lit, :x)),
|
2802
2572
|
s(:undef, s(:lit, :y)))),
|
@@ -2805,7 +2575,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2805
2575
|
add_tests("undef_block_3",
|
2806
2576
|
"Ruby" => "f1\nundef :x, :y, :z",
|
2807
2577
|
"ParseTree" => s(:block,
|
2808
|
-
s(:call, nil, :f1
|
2578
|
+
s(:call, nil, :f1),
|
2809
2579
|
s(:block,
|
2810
2580
|
s(:undef, s(:lit, :x)),
|
2811
2581
|
s(:undef, s(:lit, :y)),
|
@@ -2818,82 +2588,76 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2818
2588
|
s(:undef, s(:lit, :x)),
|
2819
2589
|
s(:undef, s(:lit, :y)),
|
2820
2590
|
s(:undef, s(:lit, :z)),
|
2821
|
-
s(:call, nil, :f2
|
2591
|
+
s(:call, nil, :f2)),
|
2822
2592
|
"Ruby2Ruby" => "undef :x\nundef :y\nundef :z\nf2\n")
|
2823
2593
|
|
2824
2594
|
add_tests("undef_block_wtf",
|
2825
2595
|
"Ruby" => "f1\nundef :x, :y, :z\nf2",
|
2826
2596
|
"ParseTree" => s(:block,
|
2827
|
-
s(:call, nil, :f1
|
2597
|
+
s(:call, nil, :f1),
|
2828
2598
|
s(:block,
|
2829
2599
|
s(:undef, s(:lit, :x)),
|
2830
2600
|
s(:undef, s(:lit, :y)),
|
2831
2601
|
s(:undef, s(:lit, :z))),
|
2832
|
-
s(:call, nil, :f2
|
2602
|
+
s(:call, nil, :f2)),
|
2833
2603
|
"Ruby2Ruby" => "f1\n(undef :x\nundef :y\nundef :z)\nf2\n")
|
2834
2604
|
|
2835
2605
|
|
2836
2606
|
add_tests("unless_post",
|
2837
2607
|
"Ruby" => "a unless b",
|
2838
|
-
"ParseTree" => s(:if, s(:call, nil, :b
|
2839
|
-
s(:call, nil, :a
|
2608
|
+
"ParseTree" => s(:if, s(:call, nil, :b), nil,
|
2609
|
+
s(:call, nil, :a)))
|
2840
2610
|
|
2841
2611
|
add_tests("unless_post_not",
|
2842
2612
|
"Ruby" => "a unless not b",
|
2843
|
-
"ParseTree" => s(:if, s(:call, nil, :b
|
2844
|
-
s(:call, nil, :a
|
2613
|
+
"ParseTree" => s(:if, s(:call, nil, :b),
|
2614
|
+
s(:call, nil, :a), nil),
|
2845
2615
|
"Ruby2Ruby" => "a if b")
|
2846
2616
|
|
2847
2617
|
add_tests("unless_pre",
|
2848
2618
|
"Ruby" => "unless b then a end",
|
2849
|
-
"ParseTree" => s(:if, s(:call, nil, :b
|
2850
|
-
s(:call, nil, :a
|
2619
|
+
"ParseTree" => s(:if, s(:call, nil, :b), nil,
|
2620
|
+
s(:call, nil, :a)),
|
2851
2621
|
"Ruby2Ruby" => "a unless b")
|
2852
2622
|
|
2853
2623
|
add_tests("unless_pre_not",
|
2854
2624
|
"Ruby" => "unless not b then a end",
|
2855
|
-
"ParseTree" => s(:if, s(:call, nil, :b
|
2856
|
-
s(:call, nil, :a
|
2625
|
+
"ParseTree" => s(:if, s(:call, nil, :b),
|
2626
|
+
s(:call, nil, :a), nil),
|
2857
2627
|
"Ruby2Ruby" => "a if b")
|
2858
2628
|
|
2859
2629
|
add_tests("until_post",
|
2860
2630
|
"Ruby" => "begin\n (1 + 1)\nend until false",
|
2861
2631
|
"ParseTree" => s(:until, s(:false),
|
2862
|
-
s(:call, s(:lit, 1), :+,
|
2863
|
-
s(:arglist, s(:lit, 1))), false))
|
2632
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1)), false))
|
2864
2633
|
|
2865
2634
|
add_tests("until_post_not",
|
2866
2635
|
"Ruby" => "begin\n (1 + 1)\nend until not true",
|
2867
2636
|
"ParseTree" => s(:while, s(:true),
|
2868
|
-
s(:call, s(:lit, 1), :+,
|
2869
|
-
s(:arglist, s(:lit, 1))), false),
|
2637
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1)), false),
|
2870
2638
|
"Ruby2Ruby" => "begin\n (1 + 1)\nend while true")
|
2871
2639
|
|
2872
2640
|
add_tests("until_pre",
|
2873
2641
|
"Ruby" => "until false do\n (1 + 1)\nend",
|
2874
2642
|
"ParseTree" => s(:until, s(:false),
|
2875
|
-
s(:call, s(:lit, 1), :+,
|
2876
|
-
s(:arglist, s(:lit, 1))), true))
|
2643
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1)), true))
|
2877
2644
|
|
2878
2645
|
add_tests("until_pre_mod",
|
2879
2646
|
"Ruby" => "(1 + 1) until false",
|
2880
2647
|
"ParseTree" => s(:until, s(:false),
|
2881
|
-
s(:call, s(:lit, 1), :+,
|
2882
|
-
s(:arglist, s(:lit, 1))), true),
|
2648
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1)), true),
|
2883
2649
|
"Ruby2Ruby" => "until false do\n (1 + 1)\nend")
|
2884
2650
|
|
2885
2651
|
add_tests("until_pre_not",
|
2886
2652
|
"Ruby" => "until not true do\n (1 + 1)\nend",
|
2887
2653
|
"ParseTree" => s(:while, s(:true),
|
2888
|
-
s(:call, s(:lit, 1), :+,
|
2889
|
-
s(:arglist, s(:lit, 1))), true),
|
2654
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1)), true),
|
2890
2655
|
"Ruby2Ruby" => "while true do\n (1 + 1)\nend")
|
2891
2656
|
|
2892
2657
|
add_tests("until_pre_not_mod",
|
2893
2658
|
"Ruby" => "(1 + 1) until not true",
|
2894
2659
|
"ParseTree" => s(:while, s(:true),
|
2895
|
-
s(:call, s(:lit, 1), :+,
|
2896
|
-
s(:arglist, s(:lit, 1))), true),
|
2660
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1)), true),
|
2897
2661
|
"Ruby2Ruby" => "while true do\n (1 + 1)\nend")
|
2898
2662
|
|
2899
2663
|
add_tests("valias",
|
@@ -2902,42 +2666,36 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2902
2666
|
|
2903
2667
|
add_tests("vcall",
|
2904
2668
|
"Ruby" => "method",
|
2905
|
-
"ParseTree" => s(:call, nil, :method
|
2669
|
+
"ParseTree" => s(:call, nil, :method))
|
2906
2670
|
|
2907
2671
|
add_tests("while_post",
|
2908
2672
|
"Ruby" => "begin\n (1 + 1)\nend while false",
|
2909
2673
|
"ParseTree" => s(:while, s(:false),
|
2910
|
-
s(:call, s(:lit, 1), :+,
|
2911
|
-
s(:arglist, s(:lit, 1))), false))
|
2674
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1)), false))
|
2912
2675
|
|
2913
2676
|
add_tests("while_post2",
|
2914
2677
|
"Ruby" => "begin\n (1 + 2)\n (3 + 4)\nend while false",
|
2915
2678
|
"ParseTree" => s(:while, s(:false),
|
2916
2679
|
s(:block,
|
2917
|
-
s(:call, s(:lit, 1), :+,
|
2918
|
-
|
2919
|
-
s(:call, s(:lit, 3), :+,
|
2920
|
-
s(:arglist, s(:lit, 4)))),
|
2680
|
+
s(:call, s(:lit, 1), :+, s(:lit, 2)),
|
2681
|
+
s(:call, s(:lit, 3), :+, s(:lit, 4))),
|
2921
2682
|
false))
|
2922
2683
|
|
2923
2684
|
add_tests("while_post_not",
|
2924
2685
|
"Ruby" => "begin\n (1 + 1)\nend while not true",
|
2925
2686
|
"ParseTree" => s(:until, s(:true),
|
2926
|
-
s(:call, s(:lit, 1), :+,
|
2927
|
-
s(:arglist, s(:lit, 1))), false),
|
2687
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1)), false),
|
2928
2688
|
"Ruby2Ruby" => "begin\n (1 + 1)\nend until true")
|
2929
2689
|
|
2930
2690
|
add_tests("while_pre",
|
2931
2691
|
"Ruby" => "while false do\n (1 + 1)\nend",
|
2932
2692
|
"ParseTree" => s(:while, s(:false),
|
2933
|
-
s(:call, s(:lit, 1), :+,
|
2934
|
-
s(:arglist, s(:lit, 1))), true))
|
2693
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1)), true))
|
2935
2694
|
|
2936
2695
|
add_tests("while_pre_mod",
|
2937
2696
|
"Ruby" => "(1 + 1) while false",
|
2938
2697
|
"ParseTree" => s(:while, s(:false),
|
2939
|
-
s(:call, s(:lit, 1), :+,
|
2940
|
-
s(:arglist, s(:lit, 1))), true),
|
2698
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1)), true),
|
2941
2699
|
"Ruby2Ruby" => "while false do\n (1 + 1)\nend") # FIX can be one liner
|
2942
2700
|
|
2943
2701
|
add_tests("while_pre_nil",
|
@@ -2947,15 +2705,13 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2947
2705
|
add_tests("while_pre_not",
|
2948
2706
|
"Ruby" => "while not true do\n (1 + 1)\nend",
|
2949
2707
|
"ParseTree" => s(:until, s(:true),
|
2950
|
-
s(:call, s(:lit, 1), :+,
|
2951
|
-
s(:arglist, s(:lit, 1))), true),
|
2708
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1)), true),
|
2952
2709
|
"Ruby2Ruby" => "until true do\n (1 + 1)\nend")
|
2953
2710
|
|
2954
2711
|
add_tests("while_pre_not_mod",
|
2955
2712
|
"Ruby" => "(1 + 1) while not true",
|
2956
2713
|
"ParseTree" => s(:until, s(:true),
|
2957
|
-
s(:call, s(:lit, 1), :+,
|
2958
|
-
s(:arglist, s(:lit, 1))), true),
|
2714
|
+
s(:call, s(:lit, 1), :+, s(:lit, 1)), true),
|
2959
2715
|
"Ruby2Ruby" => "until true do\n (1 + 1)\nend") # FIX
|
2960
2716
|
|
2961
2717
|
add_tests("xstr",
|
@@ -2992,28 +2748,27 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
2992
2748
|
|
2993
2749
|
add_tests("zsuper",
|
2994
2750
|
"Ruby" => "def x\n super\nend",
|
2995
|
-
"ParseTree" => s(:defn, :x, s(:args),
|
2996
|
-
s(:scope, s(:block, s(:zsuper)))))
|
2751
|
+
"ParseTree" => s(:defn, :x, s(:args), s(:zsuper)))
|
2997
2752
|
|
2998
2753
|
add_18tests("if_args_no_space_symbol",
|
2999
2754
|
"Ruby" => "x if y:z",
|
3000
2755
|
"ParseTree" => s(:if,
|
3001
|
-
s(:call, nil, :y,
|
3002
|
-
s(:call, nil, :x
|
2756
|
+
s(:call, nil, :y, s(:lit, :z)),
|
2757
|
+
s(:call, nil, :x),
|
3003
2758
|
nil),
|
3004
2759
|
"Ruby2Ruby" => "x if y(:z)")
|
3005
2760
|
|
3006
2761
|
add_18tests("iter_args_ivar",
|
3007
2762
|
"Ruby" => "a { |@a| 42 }",
|
3008
2763
|
"ParseTree" => s(:iter,
|
3009
|
-
s(:call, nil, :a
|
2764
|
+
s(:call, nil, :a),
|
3010
2765
|
s(:iasgn, :@a),
|
3011
2766
|
s(:lit, 42)))
|
3012
2767
|
|
3013
2768
|
add_18tests("iter_masgn_args_ivar",
|
3014
2769
|
"Ruby" => "a { |a, @b| 42 }",
|
3015
2770
|
"ParseTree" => s(:iter,
|
3016
|
-
s(:call, nil, :a
|
2771
|
+
s(:call, nil, :a),
|
3017
2772
|
s(:masgn,
|
3018
2773
|
s(:array, s(:lasgn, :a), s(:iasgn, :@b))),
|
3019
2774
|
s(:lit, 42)))
|
@@ -3052,38 +2807,38 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3052
2807
|
add_19tests("call_arglist_norm_hash_colons",
|
3053
2808
|
"Ruby" => "o.m(42, a: 1, b: 2)",
|
3054
2809
|
"ParseTree" => s(:call,
|
3055
|
-
s(:call, nil, :o
|
2810
|
+
s(:call, nil, :o),
|
3056
2811
|
:m,
|
3057
|
-
s(:
|
3058
|
-
|
3059
|
-
s(:
|
3060
|
-
|
3061
|
-
s(:lit, :b), s(:lit, 2)))))
|
2812
|
+
s(:lit, 42),
|
2813
|
+
s(:hash,
|
2814
|
+
s(:lit, :a), s(:lit, 1),
|
2815
|
+
s(:lit, :b), s(:lit, 2))))
|
3062
2816
|
|
3063
2817
|
add_19tests("call_arglist_trailing_comma",
|
3064
2818
|
"Ruby" => "a(1,2,3,)",
|
3065
|
-
|
3066
|
-
|
3067
|
-
|
2819
|
+
"ParseTree" => s(:call,
|
2820
|
+
nil,
|
2821
|
+
:a,
|
2822
|
+
s(:lit, 1), s(:lit, 2), s(:lit, 3)))
|
3068
2823
|
|
3069
2824
|
add_19tests("call_not_equal",
|
3070
2825
|
"Ruby" => "a != b",
|
3071
2826
|
"ParseTree" => s(:call,
|
3072
|
-
s(:call, nil, :a
|
2827
|
+
s(:call, nil, :a),
|
3073
2828
|
:"!=",
|
3074
|
-
s(:
|
2829
|
+
s(:call, nil, :b)))
|
3075
2830
|
|
3076
2831
|
add_19tests("call_unary_not",
|
3077
2832
|
"Ruby" => "!a",
|
3078
2833
|
"ParseTree" => s(:call,
|
3079
|
-
s(:call, nil, :a
|
3080
|
-
:"!@"
|
2834
|
+
s(:call, nil, :a),
|
2835
|
+
:"!@"))
|
3081
2836
|
|
3082
2837
|
add_19tests("defn_args_splat_mand",
|
3083
2838
|
"Ruby" => "def f(*rest, mand)\n # do nothing\nend",
|
3084
2839
|
"ParseTree" => s(:defn, :f,
|
3085
2840
|
s(:args, :"*rest", :mand),
|
3086
|
-
s(:
|
2841
|
+
s(:nil)))
|
3087
2842
|
|
3088
2843
|
add_19tests("defn_args_mand_opt_splat_mand",
|
3089
2844
|
"Ruby" => "def f(mand1, opt = 42, *rest, mand2)\n # do nothing\nend",
|
@@ -3091,7 +2846,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3091
2846
|
s(:args, :mand1, :opt, :"*rest", :mand2,
|
3092
2847
|
s(:block,
|
3093
2848
|
s(:lasgn, :opt, s(:lit, 42)))),
|
3094
|
-
s(:
|
2849
|
+
s(:nil)))
|
3095
2850
|
|
3096
2851
|
add_19tests("defn_args_mand_opt_mand",
|
3097
2852
|
"Ruby" => "def f(mand1, opt = 42, mand2)\n # do nothing\nend",
|
@@ -3099,7 +2854,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3099
2854
|
s(:args, :mand1, :opt, :mand2,
|
3100
2855
|
s(:block,
|
3101
2856
|
s(:lasgn, :opt, s(:lit, 42)))),
|
3102
|
-
s(:
|
2857
|
+
s(:nil)))
|
3103
2858
|
|
3104
2859
|
add_19tests("defn_args_opt_splat_mand",
|
3105
2860
|
"Ruby" => "def f(opt = 42, *rest, mand)\n # do nothing\nend",
|
@@ -3107,7 +2862,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3107
2862
|
s(:args, :opt, :"*rest", :mand,
|
3108
2863
|
s(:block,
|
3109
2864
|
s(:lasgn, :opt, s(:lit, 42)))),
|
3110
|
-
s(:
|
2865
|
+
s(:nil)))
|
3111
2866
|
|
3112
2867
|
add_19tests("defn_args_opt_mand",
|
3113
2868
|
"Ruby" => "def f(opt = 42, mand)\n # do nothing\nend",
|
@@ -3115,21 +2870,20 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3115
2870
|
s(:args, :opt, :mand,
|
3116
2871
|
s(:block,
|
3117
2872
|
s(:lasgn, :opt, s(:lit, 42)))),
|
3118
|
-
s(:
|
2873
|
+
s(:nil)))
|
3119
2874
|
|
3120
2875
|
add_19tests("defn_args_splat_middle",
|
3121
2876
|
"Ruby" => "def f(first, *middle, last)\n # do nothing\nend",
|
3122
2877
|
"ParseTree" => s(:defn, :f,
|
3123
2878
|
s(:args, :first, :"*middle", :last),
|
3124
|
-
s(:
|
2879
|
+
s(:nil)))
|
3125
2880
|
|
3126
2881
|
add_19tests("fcall_arglist_hash_colons",
|
3127
2882
|
"Ruby" => "m(a: 1, b: 2)",
|
3128
2883
|
"ParseTree" => s(:call, nil, :m,
|
3129
|
-
s(:
|
3130
|
-
s(:
|
3131
|
-
|
3132
|
-
s(:lit, :b), s(:lit, 2)))))
|
2884
|
+
s(:hash,
|
2885
|
+
s(:lit, :a), s(:lit, 1),
|
2886
|
+
s(:lit, :b), s(:lit, 2))))
|
3133
2887
|
|
3134
2888
|
add_19tests("hash_new",
|
3135
2889
|
"Ruby" => "{ a: 1, b: 2 }",
|
@@ -3146,14 +2900,14 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3146
2900
|
add_tests("lambda_args_anon_star",
|
3147
2901
|
"Ruby" => "lambda { |*| nil }",
|
3148
2902
|
"ParseTree" => s(:iter,
|
3149
|
-
s(:call, nil, :lambda
|
2903
|
+
s(:call, nil, :lambda),
|
3150
2904
|
s(:masgn, s(:array, s(:splat))),
|
3151
2905
|
s(:nil)))
|
3152
2906
|
|
3153
2907
|
add_tests("lambda_args_anon_star_block",
|
3154
2908
|
"Ruby" => "lambda { |*, &block| block }",
|
3155
2909
|
"ParseTree" => s(:iter,
|
3156
|
-
s(:call, nil, :lambda
|
2910
|
+
s(:call, nil, :lambda),
|
3157
2911
|
s(:masgn, s(:array,
|
3158
2912
|
s(:splat),
|
3159
2913
|
s(:lasgn, :"&block"))),
|
@@ -3162,14 +2916,14 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3162
2916
|
add_tests("lambda_args_block",
|
3163
2917
|
"Ruby" => "lambda { |&block| block }",
|
3164
2918
|
"ParseTree" => s(:iter,
|
3165
|
-
s(:call, nil, :lambda
|
2919
|
+
s(:call, nil, :lambda),
|
3166
2920
|
s(:lasgn, :"&block"),
|
3167
2921
|
s(:lvar, :block)))
|
3168
2922
|
|
3169
2923
|
add_tests("lambda_args_norm_anon_star",
|
3170
2924
|
"Ruby" => "lambda { |a, *| a }",
|
3171
2925
|
"ParseTree" => s(:iter,
|
3172
|
-
s(:call, nil, :lambda
|
2926
|
+
s(:call, nil, :lambda),
|
3173
2927
|
s(:masgn, s(:array,
|
3174
2928
|
s(:lasgn, :a),
|
3175
2929
|
s(:splat))),
|
@@ -3178,7 +2932,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3178
2932
|
add_tests("lambda_args_norm_anon_star_block",
|
3179
2933
|
"Ruby" => "lambda { |a, *, &block| block }",
|
3180
2934
|
"ParseTree" => s(:iter,
|
3181
|
-
s(:call, nil, :lambda
|
2935
|
+
s(:call, nil, :lambda),
|
3182
2936
|
s(:masgn, s(:array,
|
3183
2937
|
s(:lasgn, :a),
|
3184
2938
|
s(:splat),
|
@@ -3188,7 +2942,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3188
2942
|
add_tests("lambda_args_norm_block",
|
3189
2943
|
"Ruby" => "lambda { |a, &block| block }",
|
3190
2944
|
"ParseTree" => s(:iter,
|
3191
|
-
s(:call, nil, :lambda
|
2945
|
+
s(:call, nil, :lambda),
|
3192
2946
|
s(:masgn, s(:array,
|
3193
2947
|
s(:lasgn, :a),
|
3194
2948
|
s(:lasgn, :"&block"))),
|
@@ -3197,7 +2951,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3197
2951
|
add_tests("lambda_args_norm_comma",
|
3198
2952
|
"Ruby" => "lambda { |a,| a }",
|
3199
2953
|
"ParseTree" => s(:iter,
|
3200
|
-
s(:call, nil, :lambda
|
2954
|
+
s(:call, nil, :lambda),
|
3201
2955
|
s(:lasgn, :a),
|
3202
2956
|
s(:lvar, :a)),
|
3203
2957
|
"Ruby2Ruby" => "lambda { |a| a }")
|
@@ -3205,7 +2959,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3205
2959
|
add_tests("lambda_args_norm_comma2",
|
3206
2960
|
"Ruby" => "lambda { |a,b,| a }",
|
3207
2961
|
"ParseTree" => s(:iter,
|
3208
|
-
s(:call, nil, :lambda
|
2962
|
+
s(:call, nil, :lambda),
|
3209
2963
|
s(:masgn,
|
3210
2964
|
s(:array, s(:lasgn, :a), s(:lasgn, :b))),
|
3211
2965
|
s(:lvar, :a)),
|
@@ -3214,7 +2968,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3214
2968
|
add_tests("lambda_args_norm_star",
|
3215
2969
|
"Ruby" => "lambda { |a, *star| star }",
|
3216
2970
|
"ParseTree" => s(:iter,
|
3217
|
-
s(:call, nil, :lambda
|
2971
|
+
s(:call, nil, :lambda),
|
3218
2972
|
s(:masgn, s(:array,
|
3219
2973
|
s(:lasgn, :a),
|
3220
2974
|
s(:splat, s(:lasgn, :star)))),
|
@@ -3223,7 +2977,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3223
2977
|
add_tests("lambda_args_norm_star_block",
|
3224
2978
|
"Ruby" => "lambda { |a, *star, &block| block }",
|
3225
2979
|
"ParseTree" => s(:iter,
|
3226
|
-
s(:call, nil, :lambda
|
2980
|
+
s(:call, nil, :lambda),
|
3227
2981
|
s(:masgn, s(:array,
|
3228
2982
|
s(:lasgn, :a),
|
3229
2983
|
s(:splat, s(:lasgn, :star)),
|
@@ -3233,7 +2987,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3233
2987
|
add_tests("lambda_args_star",
|
3234
2988
|
"Ruby" => "lambda { |*star| star }",
|
3235
2989
|
"ParseTree" => s(:iter,
|
3236
|
-
s(:call, nil, :lambda
|
2990
|
+
s(:call, nil, :lambda),
|
3237
2991
|
s(:masgn, s(:array,
|
3238
2992
|
s(:splat, s(:lasgn, :star)))),
|
3239
2993
|
s(:lvar, :star)))
|
@@ -3241,7 +2995,7 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3241
2995
|
add_tests("lambda_args_star_block",
|
3242
2996
|
"Ruby" => "lambda { |*star, &block| block }",
|
3243
2997
|
"ParseTree" => s(:iter,
|
3244
|
-
s(:call, nil, :lambda
|
2998
|
+
s(:call, nil, :lambda),
|
3245
2999
|
s(:masgn, s(:array,
|
3246
3000
|
s(:splat, s(:lasgn, :star)),
|
3247
3001
|
s(:lasgn, :"&block"))),
|
@@ -3257,10 +3011,9 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3257
3011
|
|
3258
3012
|
add19_edgecases("lambda { (x + 1) }",
|
3259
3013
|
s(:iter,
|
3260
|
-
s(:call, nil, :lambda
|
3014
|
+
s(:call, nil, :lambda),
|
3261
3015
|
0,
|
3262
|
-
s(:call, s(:call, nil, :x, s(:
|
3263
|
-
:+, s(:arglist, s(:lit, 1)))),
|
3016
|
+
s(:call, s(:call, nil, :x), :+, s(:lit, 1))),
|
3264
3017
|
"stabby_args_0" => "->() { (x + 1) }",
|
3265
3018
|
"stabby_args_0_doend" => "->() do (x + 1) end",
|
3266
3019
|
"stabby_args_0_no_parens" => "-> { (x + 1) }",
|
@@ -3269,9 +3022,9 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3269
3022
|
|
3270
3023
|
add19_edgecases("lambda { |x| (x + 1) }",
|
3271
3024
|
s(:iter,
|
3272
|
-
s(:call, nil, :lambda
|
3025
|
+
s(:call, nil, :lambda),
|
3273
3026
|
s(:lasgn, :x),
|
3274
|
-
s(:call, s(:lvar, :x), :+, s(:
|
3027
|
+
s(:call, s(:lvar, :x), :+, s(:lit, 1))),
|
3275
3028
|
"stabby_args_1" => "->(x) { (x + 1) }",
|
3276
3029
|
"stabby_args_1_doend" => "->(x) do (x + 1) end",
|
3277
3030
|
"stabby_args_1_no_parens" => "-> x { (x + 1) }",
|
@@ -3279,13 +3032,12 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3279
3032
|
|
3280
3033
|
add19_edgecases("lambda { |x, y| (x + y) }",
|
3281
3034
|
s(:iter,
|
3282
|
-
s(:call, nil, :lambda
|
3035
|
+
s(:call, nil, :lambda),
|
3283
3036
|
s(:masgn,
|
3284
3037
|
s(:array,
|
3285
3038
|
s(:lasgn, :x),
|
3286
3039
|
s(:lasgn, :y))),
|
3287
|
-
s(:call, s(:lvar, :x), :+,
|
3288
|
-
s(:arglist, s(:lvar, :y)))),
|
3040
|
+
s(:call, s(:lvar, :x), :+, s(:lvar, :y))),
|
3289
3041
|
"stabby_args_2" => "->(x, y) { (x + y) }",
|
3290
3042
|
"stabby_args_2_doend" => "->(x, y) do (x + y) end",
|
3291
3043
|
"stabby_args_2_no_parens" => "-> x, y { (x + y) }",
|
@@ -3299,11 +3051,12 @@ class ParseTreeTestCase < MiniTest::Unit::TestCase
|
|
3299
3051
|
|
3300
3052
|
add_19tests("splat_fcall_middle",
|
3301
3053
|
"Ruby" => "meth(1, *[2], 3)",
|
3302
|
-
"ParseTree" => s(:call,
|
3303
|
-
|
3304
|
-
|
3305
|
-
|
3306
|
-
|
3054
|
+
"ParseTree" => s(:call,
|
3055
|
+
nil,
|
3056
|
+
:meth,
|
3057
|
+
s(:lit, 1),
|
3058
|
+
s(:splat, s(:array, s(:lit, 2))),
|
3059
|
+
s(:lit, 3)))
|
3307
3060
|
|
3308
3061
|
add_19tests("str_question_control",
|
3309
3062
|
"Ruby" => '?\M-\C-a',
|