ruby_parser 3.0.0.a9 → 3.0.0.a10
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.
Potentially problematic release.
This version of ruby_parser might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/History.txt +13 -0
- data/lib/ruby18_parser.rb +23 -23
- data/lib/ruby18_parser.y +23 -23
- data/lib/ruby19_parser.rb +98 -91
- data/lib/ruby19_parser.y +98 -91
- data/lib/ruby_parser_extras.rb +50 -120
- data/test/test_ruby_parser.rb +310 -106
- metadata +4 -4
- metadata.gz.sig +0 -0
data/test/test_ruby_parser.rb
CHANGED
@@ -109,17 +109,23 @@ module TestRubyParserShared
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def test_wtf_7
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
112
|
+
rb = "a.b (1) {c}"
|
113
|
+
pt = s(:iter,
|
114
|
+
s(:call, s(:call, nil, :a), :b, s(:lit, 1)),
|
115
|
+
s(:args),
|
116
|
+
s(:call, nil, :c))
|
117
|
+
|
118
|
+
assert_parse rb, pt
|
116
119
|
end
|
117
120
|
|
118
121
|
def test_wtf_8
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
122
|
+
rb = "a::b (1) {c}"
|
123
|
+
pt = s(:iter,
|
124
|
+
s(:call, s(:call, nil, :a), :b, s(:lit, 1)),
|
125
|
+
s(:args),
|
126
|
+
s(:call, nil, :c))
|
127
|
+
|
128
|
+
assert_parse rb, pt
|
123
129
|
end
|
124
130
|
|
125
131
|
def test_attrasgn_array_lhs
|
@@ -198,7 +204,7 @@ module TestRubyParserShared
|
|
198
204
|
rb = "a do\n v = nil\n begin\n yield\n rescue Exception => v\n break\n end\nend"
|
199
205
|
pt = s(:iter,
|
200
206
|
s(:call, nil, :a),
|
201
|
-
|
207
|
+
s(:args),
|
202
208
|
s(:block,
|
203
209
|
s(:lasgn, :v, s(:nil)),
|
204
210
|
s(:rescue,
|
@@ -253,7 +259,7 @@ module TestRubyParserShared
|
|
253
259
|
s(:call, nil, :a, s(:lit, 1)),
|
254
260
|
s(:iter,
|
255
261
|
s(:call, s(:call, nil, :a), :b),
|
256
|
-
s(:
|
262
|
+
s(:args, :c)))
|
257
263
|
|
258
264
|
assert_parse rb, pt
|
259
265
|
end
|
@@ -585,7 +591,7 @@ module TestRubyParserShared
|
|
585
591
|
|
586
592
|
pt = s(:iter,
|
587
593
|
s(:call, nil, :f),
|
588
|
-
s(:
|
594
|
+
s(:args, :x, :y),
|
589
595
|
s(:call, s(:lvar, :x), :+, s(:lvar, :y)))
|
590
596
|
|
591
597
|
assert_parse_line rb, pt, 1
|
@@ -624,7 +630,7 @@ module TestRubyParserShared
|
|
624
630
|
|
625
631
|
pt = s(:iter,
|
626
632
|
s(:call, nil, :f, s(:call, nil, :a)),
|
627
|
-
s(:
|
633
|
+
s(:args, :x, :y),
|
628
634
|
s(:call, s(:lvar, :x), :+, s(:lvar, :y)))
|
629
635
|
|
630
636
|
assert_parse_line rb, pt, 1
|
@@ -639,7 +645,7 @@ module TestRubyParserShared
|
|
639
645
|
|
640
646
|
pt = s(:iter,
|
641
647
|
s(:call, nil, :f, s(:call, nil, :a)),
|
642
|
-
s(:
|
648
|
+
s(:args, :x, :y),
|
643
649
|
s(:call, s(:lvar, :x), :+, s(:lvar, :y)))
|
644
650
|
|
645
651
|
assert_parse_line rb, pt, 1
|
@@ -701,15 +707,6 @@ module TestRubyParserShared
|
|
701
707
|
assert_parse rb, pt
|
702
708
|
end
|
703
709
|
|
704
|
-
def test_bug_args
|
705
|
-
rb = "f { |(a, b)| d }"
|
706
|
-
pt = s(:iter, s(:call, nil, :f),
|
707
|
-
s(:masgn, s(:array, s(:lasgn, :a), s(:lasgn, :b))),
|
708
|
-
s(:call, nil, :d))
|
709
|
-
|
710
|
-
assert_parse rb, pt
|
711
|
-
end
|
712
|
-
|
713
710
|
def test_bug_cond_pct
|
714
711
|
rb = "case; when %r%blahblah%; end"
|
715
712
|
pt = s(:case, nil, s(:when, s(:array, s(:lit, /blahblah/)), nil), nil)
|
@@ -717,49 +714,33 @@ module TestRubyParserShared
|
|
717
714
|
assert_parse rb, pt
|
718
715
|
end
|
719
716
|
|
720
|
-
# according to 2.3.1 parser:
|
717
|
+
# according to 2.3.1 parser -- added: ON 1.8 only:
|
721
718
|
# rp.process("f { |(a,b),c| }") == rp.process("f { |((a,b),c)| }")
|
722
719
|
|
723
|
-
#
|
724
|
-
#
|
725
|
-
#
|
726
|
-
#
|
727
|
-
#
|
728
|
-
#
|
729
|
-
# s(:masgn, s(:array, s(:lasgn, :a), s(:lasgn, :b))),
|
730
|
-
# s(:lasgn, :c))))
|
731
|
-
#
|
732
|
-
# assert_parse rb, pt.dup
|
733
|
-
# end
|
720
|
+
# ruby18 -e "p lambda { |(a,b)| }.arity" # => 2
|
721
|
+
# ruby19 -e "p lambda { |(a,b)| }.arity" # => 1
|
722
|
+
# ruby18 -e "p lambda { |(a,b),c| }.arity" # => 2
|
723
|
+
# ruby19 -e "p lambda { |(a,b),c| }.arity" # => 2
|
724
|
+
# ruby18 -e "p lambda { |((a,b),c)| }.arity" # => 2
|
725
|
+
# ruby19 -e "p lambda { |((a,b),c)| }.arity" # => 1
|
734
726
|
|
735
|
-
def
|
736
|
-
rb = "f { |(
|
737
|
-
pt = s(:iter,
|
727
|
+
def test_bug_args_masgn
|
728
|
+
rb = "f { |(a, b), c| }"
|
729
|
+
pt = s(:iter,
|
738
730
|
s(:call, nil, :f),
|
739
|
-
s(:masgn,
|
740
|
-
s(:array,
|
741
|
-
s(:masgn, s(:array, s(:lasgn, :a), s(:lasgn, :b))),
|
742
|
-
s(:lasgn, :c))))
|
731
|
+
s(:args, s(:masgn, :a, :b), :c))
|
743
732
|
|
744
733
|
assert_parse rb, pt.dup
|
745
734
|
end
|
746
735
|
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
# s(:array,
|
756
|
-
# s(:masgn,
|
757
|
-
# s(:array, s(:lasgn, :a), s(:lasgn, :b))),
|
758
|
-
# s(:lasgn, :c))),
|
759
|
-
# s(:lasgn, :d))))
|
760
|
-
#
|
761
|
-
# assert_parse rb, pt
|
762
|
-
# end
|
736
|
+
def test_bug_args_masgn2
|
737
|
+
rb = "f { |((a, b), c), d| }"
|
738
|
+
pt = s(:iter,
|
739
|
+
s(:call, nil, :f),
|
740
|
+
s(:args, s(:masgn, s(:masgn, :a, :b), :c), :d))
|
741
|
+
|
742
|
+
assert_parse rb, pt
|
743
|
+
end
|
763
744
|
|
764
745
|
def ruby18
|
765
746
|
Ruby18Parser === self.processor
|
@@ -800,10 +781,7 @@ module TestRubyParserShared
|
|
800
781
|
rb = "f { |a, (b, c)| }"
|
801
782
|
pt = s(:iter,
|
802
783
|
s(:call, nil, :f),
|
803
|
-
s(:masgn,
|
804
|
-
s(:array,
|
805
|
-
s(:lasgn, :a),
|
806
|
-
s(:masgn, s(:array, s(:lasgn, :b), s(:lasgn, :c))))))
|
784
|
+
s(:args, :a, s(:masgn, :b, :c)))
|
807
785
|
|
808
786
|
assert_parse rb, pt
|
809
787
|
end
|
@@ -862,14 +840,7 @@ module TestRubyParserShared
|
|
862
840
|
end
|
863
841
|
|
864
842
|
def test_magic_encoding_comment
|
865
|
-
rb =
|
866
|
-
# encoding: utf-8
|
867
|
-
class ExampleUTF8ClassNameVarietà
|
868
|
-
def self.è
|
869
|
-
così = :però
|
870
|
-
end
|
871
|
-
end
|
872
|
-
EOM
|
843
|
+
rb = "# encoding: utf-8\nclass ExampleUTF8ClassNameVarietà; def self.è; così = :però; end\nend\n"
|
873
844
|
|
874
845
|
rb.force_encoding "ASCII-8BIT" if rb.respond_to? :force_encoding
|
875
846
|
|
@@ -887,6 +858,20 @@ module TestRubyParserShared
|
|
887
858
|
assert_parse rb, pt
|
888
859
|
end
|
889
860
|
end
|
861
|
+
|
862
|
+
def test_iter_args_1
|
863
|
+
rb = "f { |a,b| }"
|
864
|
+
pt = s(:iter, s(:call, nil, :f), s(:args, :a, :b))
|
865
|
+
|
866
|
+
assert_parse rb, pt
|
867
|
+
end
|
868
|
+
|
869
|
+
def test_iter_args_3
|
870
|
+
rb = "f { |a, (b, c), d| }"
|
871
|
+
pt = s(:iter, s(:call, nil, :f), s(:args, :a, s(:masgn, :b, :c), :d))
|
872
|
+
|
873
|
+
assert_parse rb, pt
|
874
|
+
end
|
890
875
|
end
|
891
876
|
|
892
877
|
class TestRubyParser < MiniTest::Unit::TestCase
|
@@ -1061,6 +1046,33 @@ class TestRuby18Parser < RubyParserTestCase
|
|
1061
1046
|
def test_double_block_error_16
|
1062
1047
|
assert_syntax_error "m::a (1, &b) do end", BLOCK_DUP_MSG
|
1063
1048
|
end
|
1049
|
+
|
1050
|
+
# In 1.8, block args with an outer set of parens are superfluous.
|
1051
|
+
# In 1.9, outer set of parens are NOT... they are an explicit extra masgn.
|
1052
|
+
|
1053
|
+
def test_iter_args_2_18
|
1054
|
+
rb = "f { |(a, b)| }"
|
1055
|
+
pt = s(:iter, s(:call, nil, :f), s(:args, :a, :b))
|
1056
|
+
|
1057
|
+
assert_parse rb, pt
|
1058
|
+
end
|
1059
|
+
|
1060
|
+
def test_bug_args__18
|
1061
|
+
rb = "f { |(a, b)| }"
|
1062
|
+
pt = s(:iter, s(:call, nil, :f),
|
1063
|
+
s(:args, :a, :b))
|
1064
|
+
|
1065
|
+
assert_parse rb, pt
|
1066
|
+
end
|
1067
|
+
|
1068
|
+
def test_bug_args_masgn_outer_parens__18
|
1069
|
+
rb = "f { |((a, b), c)| }"
|
1070
|
+
pt = s(:iter, # NOTE: same sexp as test_bug_args_masgn
|
1071
|
+
s(:call, nil, :f),
|
1072
|
+
s(:args, s(:masgn, :a, :b), :c))
|
1073
|
+
|
1074
|
+
assert_parse rb, pt.dup
|
1075
|
+
end
|
1064
1076
|
end
|
1065
1077
|
|
1066
1078
|
class TestRuby19Parser < RubyParserTestCase
|
@@ -1155,7 +1167,11 @@ class TestRuby19Parser < RubyParserTestCase
|
|
1155
1167
|
|
1156
1168
|
def test_encoding
|
1157
1169
|
rb = '__ENCODING__'
|
1158
|
-
pt =
|
1170
|
+
pt = if defined? Encoding then
|
1171
|
+
s(:const, Encoding::UTF_8)
|
1172
|
+
else
|
1173
|
+
s(:str, "Unsupported!")
|
1174
|
+
end
|
1159
1175
|
|
1160
1176
|
assert_parse rb, pt
|
1161
1177
|
end
|
@@ -1286,7 +1302,7 @@ class TestRuby19Parser < RubyParserTestCase
|
|
1286
1302
|
rb = "a { |b = 1| }"
|
1287
1303
|
pt = s(:iter,
|
1288
1304
|
s(:call, nil, :a),
|
1289
|
-
s(:args,
|
1305
|
+
s(:args, s(:lasgn, :b, s(:lit, 1))))
|
1290
1306
|
|
1291
1307
|
assert_parse rb, pt
|
1292
1308
|
end
|
@@ -1303,7 +1319,7 @@ class TestRuby19Parser < RubyParserTestCase
|
|
1303
1319
|
s(:lit, :a),
|
1304
1320
|
s(:iter,
|
1305
1321
|
s(:call, nil, :lambda),
|
1306
|
-
|
1322
|
+
s(:args),
|
1307
1323
|
s(:if, s(:call, nil, :b), s(:call, nil, :c), s(:call, nil, :d))),
|
1308
1324
|
|
1309
1325
|
s(:lit, :e),
|
@@ -1319,34 +1335,31 @@ class TestRuby19Parser < RubyParserTestCase
|
|
1319
1335
|
# assert_parse rb, pt
|
1320
1336
|
# end
|
1321
1337
|
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
# assert_parse rb, pt
|
1342
|
-
# end
|
1338
|
+
def test_wtf
|
1339
|
+
# lambda -> f_larglist lambda_body
|
1340
|
+
# f_larglist -> f_args opt_bv_decl
|
1341
|
+
# opt_bv_decl
|
1342
|
+
# bv_decls
|
1343
|
+
# bvar
|
1344
|
+
|
1345
|
+
rb = "->(a, b=nil) { p [a, b] }"
|
1346
|
+
pt = s(:iter,
|
1347
|
+
s(:call, nil, :lambda),
|
1348
|
+
s(:args, :a, s(:lasgn, :b, s(:nil))),
|
1349
|
+
s(:call, nil, :p, s(:array, s(:lvar, :a), s(:lvar, :b))))
|
1350
|
+
|
1351
|
+
assert_parse rb, pt
|
1352
|
+
|
1353
|
+
# rb = "->(a; b) { p [a, b] }"
|
1354
|
+
#
|
1355
|
+
# assert_parse rb, pt
|
1356
|
+
end
|
1343
1357
|
|
1344
1358
|
def test_block_args_opt1
|
1345
1359
|
rb = "f { |a, b = 42| [a, b] }"
|
1346
1360
|
pt = s(:iter,
|
1347
1361
|
s(:call, nil, :f),
|
1348
|
-
s(:args, :a, :b,
|
1349
|
-
s(:block, s(:lasgn, :b, s(:lit, 42)))),
|
1362
|
+
s(:args, :a, s(:lasgn, :b, s(:lit, 42))),
|
1350
1363
|
s(:array, s(:lvar, :a), s(:lvar, :b)))
|
1351
1364
|
|
1352
1365
|
assert_parse rb, pt
|
@@ -1356,8 +1369,7 @@ class TestRuby19Parser < RubyParserTestCase
|
|
1356
1369
|
rb = "f { |a, b = 42, c = 24| [a, b, c] }"
|
1357
1370
|
pt = s(:iter,
|
1358
1371
|
s(:call, nil, :f),
|
1359
|
-
s(:args, :a, :b, :c,
|
1360
|
-
s(:block, s(:lasgn, :b, s(:lit, 42)), s(:lasgn, :c, s(:lit, 24)))),
|
1372
|
+
s(:args, :a, s(:lasgn, :b, s(:lit, 42)), s(:lasgn, :c, s(:lit, 24))),
|
1361
1373
|
s(:array, s(:lvar, :a), s(:lvar, :b), s(:lvar, :c)))
|
1362
1374
|
|
1363
1375
|
assert_parse rb, pt
|
@@ -1367,8 +1379,7 @@ class TestRuby19Parser < RubyParserTestCase
|
|
1367
1379
|
rb = "f { |a, b = 42, c = 24, &d| [a, b, c, d] }"
|
1368
1380
|
pt = s(:iter,
|
1369
1381
|
s(:call, nil, :f),
|
1370
|
-
s(:args, :a, :b, :c, :"&d",
|
1371
|
-
s(:block, s(:lasgn, :b, s(:lit, 42)), s(:lasgn, :c, s(:lit, 24)))),
|
1382
|
+
s(:args, :a, s(:lasgn, :b, s(:lit, 42)), s(:lasgn, :c, s(:lit, 24)), :"&d"),
|
1372
1383
|
s(:array, s(:lvar, :a), s(:lvar, :b), s(:lvar, :c), s(:lvar, :d)))
|
1373
1384
|
|
1374
1385
|
assert_parse rb, pt
|
@@ -1400,13 +1411,7 @@ class TestRuby19Parser < RubyParserTestCase
|
|
1400
1411
|
rb = "f { |a, (b, *c)| }"
|
1401
1412
|
pt = s(:iter,
|
1402
1413
|
s(:call, nil, :f),
|
1403
|
-
s(:masgn,
|
1404
|
-
s(:array,
|
1405
|
-
s(:lasgn, :a),
|
1406
|
-
s(:masgn,
|
1407
|
-
s(:array,
|
1408
|
-
s(:lasgn, :b),
|
1409
|
-
s(:splat, :c)))))) # TODO: omg this is so horrible
|
1414
|
+
s(:args, :a, s(:masgn, :b, :"*c")))
|
1410
1415
|
|
1411
1416
|
assert_parse rb, pt
|
1412
1417
|
end
|
@@ -1438,4 +1443,203 @@ class TestRuby19Parser < RubyParserTestCase
|
|
1438
1443
|
#
|
1439
1444
|
# assert_parse rb, pt
|
1440
1445
|
# end
|
1446
|
+
|
1447
|
+
def test_iter_args_4
|
1448
|
+
rb = "f { |a, *b, c| }"
|
1449
|
+
pt = s(:iter, s(:call, nil, :f), s(:args, :a, :"*b", :c))
|
1450
|
+
|
1451
|
+
assert_parse rb, pt
|
1452
|
+
end
|
1453
|
+
|
1454
|
+
def test_iter_args_5
|
1455
|
+
rb = "f { |a, &b| }"
|
1456
|
+
pt = s(:iter, s(:call, nil, :f), s(:args, :a, :"&b"))
|
1457
|
+
|
1458
|
+
assert_parse rb, pt
|
1459
|
+
end
|
1460
|
+
|
1461
|
+
def test_iter_args_6
|
1462
|
+
rb = "f { |a, b=42, c| }"
|
1463
|
+
pt = s(:iter, s(:call, nil, :f), s(:args, :a, s(:lasgn, :b, s(:lit, 42)), :c))
|
1464
|
+
|
1465
|
+
assert_parse rb, pt
|
1466
|
+
end
|
1467
|
+
|
1468
|
+
# In 1.8, block args with an outer set of parens are superfluous.
|
1469
|
+
# In 1.9, outer set of parens are NOT... they are an explicit extra masgn.
|
1470
|
+
|
1471
|
+
def test_iter_args_2__19
|
1472
|
+
rb = "f { |(a, b)| }"
|
1473
|
+
pt = s(:iter, s(:call, nil, :f), s(:args, s(:masgn, :a, :b)))
|
1474
|
+
|
1475
|
+
assert_parse rb, pt
|
1476
|
+
end
|
1477
|
+
|
1478
|
+
def test_bug_args__19
|
1479
|
+
rb = "f { |(a, b)| d }"
|
1480
|
+
pt = s(:iter, s(:call, nil, :f),
|
1481
|
+
s(:args, s(:masgn, :a, :b)),
|
1482
|
+
s(:call, nil, :d))
|
1483
|
+
|
1484
|
+
assert_parse rb, pt
|
1485
|
+
end
|
1486
|
+
|
1487
|
+
def test_bug_args_masgn_outer_parens__19
|
1488
|
+
rb = "f { |((k, v), i)| }"
|
1489
|
+
pt = s(:iter, # NOTE: same sexp as test_bug_args_masgn
|
1490
|
+
s(:call, nil, :f),
|
1491
|
+
s(:args, s(:masgn, s(:masgn, :k, :v), :i)))
|
1492
|
+
|
1493
|
+
assert_parse rb, pt.dup
|
1494
|
+
end
|
1495
|
+
|
1496
|
+
def test_iter_args_7_1
|
1497
|
+
rb = "f { |a = 42, *b| }"
|
1498
|
+
pt = s(:iter, s(:call, nil, :f),
|
1499
|
+
s(:args, s(:lasgn, :a, s(:lit, 42)), :"*b"))
|
1500
|
+
|
1501
|
+
assert_parse rb, pt
|
1502
|
+
end
|
1503
|
+
|
1504
|
+
def test_iter_args_7_2
|
1505
|
+
rb = "f { |a = 42, *b, &c| }"
|
1506
|
+
pt = s(:iter, s(:call, nil, :f),
|
1507
|
+
s(:args, s(:lasgn, :a, s(:lit, 42)), :"*b", :"&c"))
|
1508
|
+
|
1509
|
+
assert_parse rb, pt
|
1510
|
+
end
|
1511
|
+
|
1512
|
+
def test_iter_args_8_1
|
1513
|
+
rb = "f { |a = 42, *b, c| }"
|
1514
|
+
pt = s(:iter, s(:call, nil, :f),
|
1515
|
+
s(:args, s(:lasgn, :a, s(:lit, 42)), :"*b", :c))
|
1516
|
+
|
1517
|
+
assert_parse rb, pt
|
1518
|
+
end
|
1519
|
+
|
1520
|
+
def test_iter_args_8_2
|
1521
|
+
rb = "f { |a = 42, *b, c, &d| }"
|
1522
|
+
pt = s(:iter, s(:call, nil, :f),
|
1523
|
+
s(:args, s(:lasgn, :a, s(:lit, 42)), :"*b", :c, :"&d"))
|
1524
|
+
|
1525
|
+
assert_parse rb, pt
|
1526
|
+
end
|
1527
|
+
|
1528
|
+
def test_iter_args_9_1
|
1529
|
+
rb = "f { |a = 42, b| }"
|
1530
|
+
pt = s(:iter, s(:call, nil, :f),
|
1531
|
+
s(:args, s(:lasgn, :a, s(:lit, 42)), :b))
|
1532
|
+
|
1533
|
+
assert_parse rb, pt
|
1534
|
+
end
|
1535
|
+
|
1536
|
+
def test_iter_args_9_2
|
1537
|
+
rb = "f { |a = 42, b, &c| }"
|
1538
|
+
pt = s(:iter, s(:call, nil, :f),
|
1539
|
+
s(:args, s(:lasgn, :a, s(:lit, 42)), :b, :"&c"))
|
1540
|
+
|
1541
|
+
assert_parse rb, pt
|
1542
|
+
end
|
1543
|
+
|
1544
|
+
def test_iter_args_10_1
|
1545
|
+
rb = "f { |a, b = 42, *c| }"
|
1546
|
+
pt = s(:iter, s(:call, nil, :f),
|
1547
|
+
s(:args, :a, s(:lasgn, :b, s(:lit, 42)), :"*c"))
|
1548
|
+
|
1549
|
+
assert_parse rb, pt
|
1550
|
+
end
|
1551
|
+
|
1552
|
+
def test_iter_args_10_2
|
1553
|
+
rb = "f { |a, b = 42, *c, &d| }"
|
1554
|
+
pt = s(:iter, s(:call, nil, :f),
|
1555
|
+
s(:args, :a, s(:lasgn, :b, s(:lit, 42)), :"*c", :"&d"))
|
1556
|
+
|
1557
|
+
assert_parse rb, pt
|
1558
|
+
end
|
1559
|
+
|
1560
|
+
def test_iter_args_11_1
|
1561
|
+
rb = "f { |a, b = 42, *c, d| }"
|
1562
|
+
pt = s(:iter, s(:call, nil, :f),
|
1563
|
+
s(:args, :a, s(:lasgn, :b, s(:lit, 42)), :"*c", :d))
|
1564
|
+
|
1565
|
+
assert_parse rb, pt
|
1566
|
+
end
|
1567
|
+
|
1568
|
+
def test_iter_args_11_2
|
1569
|
+
rb = "f { |a, b = 42, *c, d, &e| }"
|
1570
|
+
pt = s(:iter, s(:call, nil, :f),
|
1571
|
+
s(:args, :a, s(:lasgn, :b, s(:lit, 42)), :"*c", :d, :"&e"))
|
1572
|
+
|
1573
|
+
assert_parse rb, pt
|
1574
|
+
end
|
1575
|
+
|
1576
|
+
def test_kill_me_6
|
1577
|
+
# | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list
|
1578
|
+
rb = "f { |a, (b, *c, d)| }"
|
1579
|
+
pt = s(:iter,
|
1580
|
+
s(:call, nil, :f),
|
1581
|
+
s(:args, :a, s(:masgn, :b, :"*c", :d)))
|
1582
|
+
|
1583
|
+
assert_parse rb, pt
|
1584
|
+
end
|
1585
|
+
|
1586
|
+
def test_kill_me_7
|
1587
|
+
# | f_marg_list tCOMMA tSTAR
|
1588
|
+
rb = "f { |a, (b, *)| }"
|
1589
|
+
pt = s(:iter,
|
1590
|
+
s(:call, nil, :f),
|
1591
|
+
s(:args, :a, s(:masgn, :b, :*)))
|
1592
|
+
|
1593
|
+
assert_parse rb, pt
|
1594
|
+
end
|
1595
|
+
|
1596
|
+
def test_kill_me_8
|
1597
|
+
# | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list
|
1598
|
+
rb = "f { |a, (b, *, c)| }"
|
1599
|
+
pt = s(:iter,
|
1600
|
+
s(:call, nil, :f),
|
1601
|
+
s(:args, :a, s(:masgn, :b, :*, :c)))
|
1602
|
+
|
1603
|
+
assert_parse rb, pt
|
1604
|
+
end
|
1605
|
+
|
1606
|
+
def test_kill_me_9
|
1607
|
+
# | tSTAR f_norm_arg
|
1608
|
+
rb = "f { |a, (*b)| }"
|
1609
|
+
pt = s(:iter,
|
1610
|
+
s(:call, nil, :f),
|
1611
|
+
s(:args, :a, s(:masgn, :"*b")))
|
1612
|
+
|
1613
|
+
assert_parse rb, pt
|
1614
|
+
end
|
1615
|
+
|
1616
|
+
def test_kill_me_10
|
1617
|
+
# | tSTAR f_norm_arg tCOMMA f_marg_list
|
1618
|
+
rb = "f { |a, (*b, c)| }"
|
1619
|
+
pt = s(:iter,
|
1620
|
+
s(:call, nil, :f),
|
1621
|
+
s(:args, :a, s(:masgn, :"*b", :c)))
|
1622
|
+
|
1623
|
+
assert_parse rb, pt
|
1624
|
+
end
|
1625
|
+
|
1626
|
+
def test_kill_me_11
|
1627
|
+
# | tSTAR
|
1628
|
+
rb = "f { |a, (*)| }"
|
1629
|
+
pt = s(:iter,
|
1630
|
+
s(:call, nil, :f),
|
1631
|
+
s(:args, :a, s(:masgn, :*)))
|
1632
|
+
|
1633
|
+
assert_parse rb, pt
|
1634
|
+
end
|
1635
|
+
|
1636
|
+
def test_kill_me_12
|
1637
|
+
# | tSTAR tCOMMA f_marg_list
|
1638
|
+
rb = "f { |a, (*, b)| }"
|
1639
|
+
pt = s(:iter,
|
1640
|
+
s(:call, nil, :f),
|
1641
|
+
s(:args, :a, s(:masgn, :*, :b)))
|
1642
|
+
|
1643
|
+
assert_parse rb, pt
|
1644
|
+
end
|
1441
1645
|
end
|