ruby_parser
Advanced tools
+13
-0
@@ -0,1 +1,14 @@ | ||
| === 3.0.0.a10 / 2012-10-26 | ||
| * 1 major enhancement: | ||
| * iter nodes are now structurally the same as defs. Block args are COMPLETELY different. | ||
| * 4 minor enhancements: | ||
| * 1.8 and 1.9 now treat f { |(...)| } differently, per MRI. | ||
| * 1.9: Added __ENCODING__ support. (witlessbird) | ||
| * 1.9: Finished coverage for masgn variants in block args | ||
| * 1.9: covered all forms of block args: optional, splat, block, and destructuring | ||
| === 3.0.0.a9 / 2012-10-22 | ||
@@ -2,0 +15,0 @@ |
+50
-120
@@ -88,3 +88,3 @@ # encoding: ASCII-8BIT | ||
| module RubyParserStuff | ||
| VERSION = '3.0.0.a9' unless constants.include? "VERSION" # SIGH | ||
| VERSION = '3.0.0.a10' unless constants.include? "VERSION" # SIGH | ||
@@ -119,150 +119,72 @@ attr_accessor :lexer, :in_def, :in_single, :file | ||
| def block_var ary, splat, block | ||
| ary ||= s(:array) | ||
| if splat then | ||
| if splat == s(:splat) then | ||
| ary << splat | ||
| def clean_mlhs sexp | ||
| case sexp.sexp_type | ||
| when :masgn then | ||
| if sexp.size == 2 and sexp[1].sexp_type == :array then | ||
| s(:masgn, *sexp[1][1..-1].map { |sub| clean_mlhs sub }) | ||
| else | ||
| ary << s(:splat, splat) | ||
| sexp | ||
| end | ||
| when :gasgn, :iasgn, :lasgn, :cvasgn then | ||
| if sexp.size == 2 then | ||
| sexp.last | ||
| else | ||
| sexp # optional value | ||
| end | ||
| else | ||
| raise "unsupported type: #{sexp.inspect}" | ||
| end | ||
| end | ||
| if block then | ||
| block[-1] = :"&#{block[-1]}" | ||
| ary << block | ||
| end | ||
| result = if ary.length > 2 or ary.splat then | ||
| s(:masgn, ary) | ||
| else | ||
| ary.last | ||
| end | ||
| def block_var *args | ||
| result = self.args args | ||
| result[0] = :masgn | ||
| result | ||
| end | ||
| def args arg, optarg, rest_arg, block_arg, post_arg = nil | ||
| arg ||= s(:args) | ||
| def block_var18 ary, splat, block | ||
| ary ||= s(:array) | ||
| result = arg | ||
| if optarg then | ||
| optarg[1..-1].each do |lasgn| # FIX clean sexp iter | ||
| raise "wtf? #{lasgn.inspect}" unless lasgn[0] == :lasgn | ||
| result << lasgn[1] | ||
| end | ||
| if splat then | ||
| splat = splat[1] unless Symbol === splat | ||
| ary << "*#{splat}".to_sym | ||
| end | ||
| result << rest_arg if rest_arg | ||
| ary << "&#{block[1]}".to_sym if block | ||
| result << :"&#{block_arg.last}" if block_arg | ||
| result << optarg if optarg # TODO? huh - processed above as well | ||
| post_arg[1..-1].each {|pa| result << pa } if post_arg | ||
| result | ||
| if ary.length > 2 or ary.splat then # HACK | ||
| s(:masgn, *ary[1..-1]) | ||
| else | ||
| ary.last | ||
| end | ||
| end | ||
| def args19 vals # TODO: migrate to args once 1.8 tests pass as well | ||
| def args args | ||
| result = s(:args) | ||
| block = nil | ||
| vals.each do |val| | ||
| case val | ||
| args.each do |arg| | ||
| case arg | ||
| when Sexp then | ||
| case val.first | ||
| when :args then | ||
| val[1..-1].each do |name| | ||
| result << name | ||
| end | ||
| case arg.sexp_type | ||
| when :args, :block, :array then | ||
| result.concat arg[1..-1] | ||
| when :block_arg then | ||
| result << :"&#{val.last}" | ||
| when :block then | ||
| block = val | ||
| val[1..-1].each do |lasgn| # FIX clean sexp iter | ||
| raise "wtf? #{val.inspect}" unless lasgn[0] == :lasgn | ||
| result << lasgn[1] | ||
| end | ||
| when :lasgn then | ||
| result << val | ||
| result << :"&#{arg.last}" | ||
| when :masgn then | ||
| result << arg | ||
| else | ||
| raise "unhandled sexp: #{val.inspect}" | ||
| raise "unhandled: #{arg.inspect}" | ||
| end | ||
| when Symbol then | ||
| result << val | ||
| result << arg | ||
| when ",", nil then | ||
| # ignore | ||
| else | ||
| raise "unhandled val: #{val.inspect} in #{vals.inspect}" | ||
| raise "unhandled: #{arg.inspect}" | ||
| end | ||
| end | ||
| result << block if block | ||
| result | ||
| end | ||
| def block_args19 val, id | ||
| # HACK OMG THIS CODE IS SOOO UGLY! CLEAN ME | ||
| untested = %w[1 2 3 4 7 9 10 12 14] | ||
| raise "no block_args19 #{id}\non: #{val.inspect}" if untested.include? id | ||
| r = s(:array) | ||
| val.compact.each do |v| | ||
| next if %w[,].include? v | ||
| case v | ||
| when Sexp then | ||
| case v.first | ||
| when :args then | ||
| r.concat v[1..-1].map { |s| # FIX: this is a smell | ||
| case s | ||
| when Symbol then | ||
| s(:lasgn, s) | ||
| when Sexp then | ||
| s | ||
| else | ||
| raise "unhandled type: #{s.inspect}" | ||
| end | ||
| } | ||
| when :block_arg then | ||
| r << s(:lasgn, :"&#{v.last}") | ||
| when :lasgn then | ||
| r << s(:masgn, s(:array, v)) | ||
| when :masgn then | ||
| r << v | ||
| else | ||
| raise "block_args19 #{id} unhandled sexp type:: #{v.inspect}" | ||
| end | ||
| when Symbol | ||
| case v.to_s | ||
| when /^\*(.+)/ then | ||
| r << s(:splat, s(:lasgn, $1.to_sym)) | ||
| when /^\*/ then | ||
| r << s(:splat) | ||
| else | ||
| raise "block_args19 #{id} unhandled symbol type:: #{v.inspect}" | ||
| end | ||
| else | ||
| raise "block_args19 #{id} unhandled type:: #{v.inspect}" | ||
| end | ||
| end | ||
| if r.size > 2 then | ||
| r = s(:masgn, r) | ||
| elsif r.size == 2 then | ||
| case r.last.first | ||
| when :splat then | ||
| r = s(:masgn, r) | ||
| when :lasgn, :masgn then | ||
| r = r.last | ||
| else | ||
| raise "oh noes!: #{r.inspect}" | ||
| end | ||
| else | ||
| raise "totally borked: #{r.inspect}" | ||
| end | ||
| r | ||
| end | ||
| def aryset receiver, index | ||
@@ -688,2 +610,7 @@ s(:attrasgn, receiver, :"[]=", *index[1..-1]) | ||
| def new_iter call, args, body | ||
| body ||= nil | ||
| args ||= s(:args) | ||
| args = s(:args, args) if Symbol === args | ||
| result = s(:iter) | ||
@@ -693,2 +620,5 @@ result << call if call | ||
| result << body if body | ||
| args[0] = :args unless args == 0 | ||
| result | ||
@@ -695,0 +625,0 @@ end |
+310
-106
@@ -112,13 +112,19 @@ #!/usr/local/bin/ruby | ||
| def test_wtf_7 | ||
| assert_parse "a.b (1) {c}", s(:iter, | ||
| s(:call, s(:call, nil, :a), :b, s(:lit, 1)), | ||
| nil, | ||
| s(:call, nil, :c)) | ||
| rb = "a.b (1) {c}" | ||
| pt = s(:iter, | ||
| s(:call, s(:call, nil, :a), :b, s(:lit, 1)), | ||
| s(:args), | ||
| s(:call, nil, :c)) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_wtf_8 | ||
| assert_parse "a::b (1) {c}", s(:iter, | ||
| s(:call, s(:call, nil, :a), :b, s(:lit, 1)), | ||
| nil, | ||
| s(:call, nil, :c)) | ||
| rb = "a::b (1) {c}" | ||
| pt = s(:iter, | ||
| s(:call, s(:call, nil, :a), :b, s(:lit, 1)), | ||
| s(:args), | ||
| s(:call, nil, :c)) | ||
| assert_parse rb, pt | ||
| end | ||
@@ -202,3 +208,3 @@ | ||
| s(:call, nil, :a), | ||
| nil, | ||
| s(:args), | ||
| s(:block, | ||
@@ -258,3 +264,3 @@ s(:lasgn, :v, s(:nil)), | ||
| s(:call, s(:call, nil, :a), :b), | ||
| s(:lasgn, :c))) | ||
| s(:args, :c))) | ||
@@ -591,3 +597,3 @@ assert_parse rb, pt | ||
| s(:call, nil, :f), | ||
| s(:masgn, s(:array, s(:lasgn, :x), s(:lasgn, :y))), | ||
| s(:args, :x, :y), | ||
| s(:call, s(:lvar, :x), :+, s(:lvar, :y))) | ||
@@ -631,3 +637,3 @@ | ||
| s(:call, nil, :f, s(:call, nil, :a)), | ||
| s(:masgn, s(:array, s(:lasgn, :x), s(:lasgn, :y))), | ||
| s(:args, :x, :y), | ||
| s(:call, s(:lvar, :x), :+, s(:lvar, :y))) | ||
@@ -647,3 +653,3 @@ | ||
| s(:call, nil, :f, s(:call, nil, :a)), | ||
| s(:masgn, s(:array, s(:lasgn, :x), s(:lasgn, :y))), | ||
| s(:args, :x, :y), | ||
| s(:call, s(:lvar, :x), :+, s(:lvar, :y))) | ||
@@ -710,11 +716,2 @@ | ||
| def test_bug_args | ||
| rb = "f { |(a, b)| d }" | ||
| pt = s(:iter, s(:call, nil, :f), | ||
| s(:masgn, s(:array, s(:lasgn, :a), s(:lasgn, :b))), | ||
| s(:call, nil, :d)) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_bug_cond_pct | ||
@@ -727,25 +724,17 @@ rb = "case; when %r%blahblah%; end" | ||
| # according to 2.3.1 parser: | ||
| # according to 2.3.1 parser -- added: ON 1.8 only: | ||
| # rp.process("f { |(a,b),c| }") == rp.process("f { |((a,b),c)| }") | ||
| # def test_bug_args_masgn | ||
| # rb = "f { |(a, b), c| }" | ||
| # pt = s(:iter, | ||
| # s(:call, nil, :f), | ||
| # s(:masgn, | ||
| # s(:array, | ||
| # s(:masgn, s(:array, s(:lasgn, :a), s(:lasgn, :b))), | ||
| # s(:lasgn, :c)))) | ||
| # | ||
| # assert_parse rb, pt.dup | ||
| # end | ||
| # ruby18 -e "p lambda { |(a,b)| }.arity" # => 2 | ||
| # ruby19 -e "p lambda { |(a,b)| }.arity" # => 1 | ||
| # ruby18 -e "p lambda { |(a,b),c| }.arity" # => 2 | ||
| # ruby19 -e "p lambda { |(a,b),c| }.arity" # => 2 | ||
| # ruby18 -e "p lambda { |((a,b),c)| }.arity" # => 2 | ||
| # ruby19 -e "p lambda { |((a,b),c)| }.arity" # => 1 | ||
| def test_bug_args_masgn_outer_parens | ||
| rb = "f { |((a, b), c)| }" | ||
| pt = s(:iter, # NOTE: same sexp as test_bug_args_masgn | ||
| def test_bug_args_masgn | ||
| rb = "f { |(a, b), c| }" | ||
| pt = s(:iter, | ||
| s(:call, nil, :f), | ||
| s(:masgn, | ||
| s(:array, | ||
| s(:masgn, s(:array, s(:lasgn, :a), s(:lasgn, :b))), | ||
| s(:lasgn, :c)))) | ||
| s(:args, s(:masgn, :a, :b), :c)) | ||
@@ -755,19 +744,11 @@ assert_parse rb, pt.dup | ||
| # TODO: | ||
| # def test_bug_args_masgn2 | ||
| # rb = "f { |((a, b), c), d| }" | ||
| # pt = s(:iter, | ||
| # s(:call, nil, :f), | ||
| # s(:masgn, | ||
| # s(:array, | ||
| # s(:masgn, | ||
| # s(:array, | ||
| # s(:masgn, | ||
| # s(:array, s(:lasgn, :a), s(:lasgn, :b))), | ||
| # s(:lasgn, :c))), | ||
| # s(:lasgn, :d)))) | ||
| # | ||
| # assert_parse rb, pt | ||
| # end | ||
| def test_bug_args_masgn2 | ||
| rb = "f { |((a, b), c), d| }" | ||
| pt = s(:iter, | ||
| s(:call, nil, :f), | ||
| s(:args, s(:masgn, s(:masgn, :a, :b), :c), :d)) | ||
| assert_parse rb, pt | ||
| end | ||
| def ruby18 | ||
@@ -812,6 +793,3 @@ Ruby18Parser === self.processor | ||
| s(:call, nil, :f), | ||
| s(:masgn, | ||
| s(:array, | ||
| s(:lasgn, :a), | ||
| s(:masgn, s(:array, s(:lasgn, :b), s(:lasgn, :c)))))) | ||
| s(:args, :a, s(:masgn, :b, :c))) | ||
@@ -875,10 +853,3 @@ assert_parse rb, pt | ||
| def test_magic_encoding_comment | ||
| rb = <<-EOM.gsub(/^ /, '') | ||
| # encoding: utf-8 | ||
| class ExampleUTF8ClassNameVarietà | ||
| def self.è | ||
| così = :però | ||
| end | ||
| end | ||
| EOM | ||
| rb = "# encoding: utf-8\nclass ExampleUTF8ClassNameVarietà; def self.è; così = :però; end\nend\n" | ||
@@ -901,2 +872,16 @@ rb.force_encoding "ASCII-8BIT" if rb.respond_to? :force_encoding | ||
| end | ||
| def test_iter_args_1 | ||
| rb = "f { |a,b| }" | ||
| pt = s(:iter, s(:call, nil, :f), s(:args, :a, :b)) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_iter_args_3 | ||
| rb = "f { |a, (b, c), d| }" | ||
| pt = s(:iter, s(:call, nil, :f), s(:args, :a, s(:masgn, :b, :c), :d)) | ||
| assert_parse rb, pt | ||
| end | ||
| end | ||
@@ -1076,2 +1061,29 @@ | ||
| end | ||
| # In 1.8, block args with an outer set of parens are superfluous. | ||
| # In 1.9, outer set of parens are NOT... they are an explicit extra masgn. | ||
| def test_iter_args_2_18 | ||
| rb = "f { |(a, b)| }" | ||
| pt = s(:iter, s(:call, nil, :f), s(:args, :a, :b)) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_bug_args__18 | ||
| rb = "f { |(a, b)| }" | ||
| pt = s(:iter, s(:call, nil, :f), | ||
| s(:args, :a, :b)) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_bug_args_masgn_outer_parens__18 | ||
| rb = "f { |((a, b), c)| }" | ||
| pt = s(:iter, # NOTE: same sexp as test_bug_args_masgn | ||
| s(:call, nil, :f), | ||
| s(:args, s(:masgn, :a, :b), :c)) | ||
| assert_parse rb, pt.dup | ||
| end | ||
| end | ||
@@ -1171,3 +1183,7 @@ | ||
| rb = '__ENCODING__' | ||
| pt = s(:str, "Unsupported!") | ||
| pt = if defined? Encoding then | ||
| s(:const, Encoding::UTF_8) | ||
| else | ||
| s(:str, "Unsupported!") | ||
| end | ||
@@ -1303,3 +1319,3 @@ assert_parse rb, pt | ||
| s(:call, nil, :a), | ||
| s(:args, :b, s(:block, s(:lasgn, :b, s(:lit, 1))))) | ||
| s(:args, s(:lasgn, :b, s(:lit, 1)))) | ||
@@ -1321,3 +1337,3 @@ assert_parse rb, pt | ||
| s(:call, nil, :lambda), | ||
| nil, | ||
| s(:args), | ||
| s(:if, s(:call, nil, :b), s(:call, nil, :c), s(:call, nil, :d))), | ||
@@ -1338,24 +1354,22 @@ | ||
| # HACK: need to figure out the desired structure and get this working | ||
| # def test_wtf | ||
| # # lambda -> f_larglist lambda_body | ||
| # # f_larglist -> f_args opt_bv_decl | ||
| # # opt_bv_decl | ||
| # # bv_decls | ||
| # # bvar | ||
| # | ||
| # rb = "->(a, b=nil) { p [a, b] }" | ||
| # pt = s(:iter, | ||
| # s(:call, nil, :lambda), | ||
| # s(:args, :a, :b, | ||
| # s(:block, s(:lasgn, :b, s(:nil)))), | ||
| # s(:call, nil, :p, s(:array, s(:lvar, :a), s(:lvar, :b)))) | ||
| # | ||
| # assert_parse rb, pt | ||
| # | ||
| # rb = "->(a; b) { p [a, b] }" | ||
| # | ||
| # assert_parse rb, pt | ||
| # end | ||
| def test_wtf | ||
| # lambda -> f_larglist lambda_body | ||
| # f_larglist -> f_args opt_bv_decl | ||
| # opt_bv_decl | ||
| # bv_decls | ||
| # bvar | ||
| rb = "->(a, b=nil) { p [a, b] }" | ||
| pt = s(:iter, | ||
| s(:call, nil, :lambda), | ||
| s(:args, :a, s(:lasgn, :b, s(:nil))), | ||
| s(:call, nil, :p, s(:array, s(:lvar, :a), s(:lvar, :b)))) | ||
| assert_parse rb, pt | ||
| # rb = "->(a; b) { p [a, b] }" | ||
| # | ||
| # assert_parse rb, pt | ||
| end | ||
| def test_block_args_opt1 | ||
@@ -1365,4 +1379,3 @@ rb = "f { |a, b = 42| [a, b] }" | ||
| s(:call, nil, :f), | ||
| s(:args, :a, :b, | ||
| s(:block, s(:lasgn, :b, s(:lit, 42)))), | ||
| s(:args, :a, s(:lasgn, :b, s(:lit, 42))), | ||
| s(:array, s(:lvar, :a), s(:lvar, :b))) | ||
@@ -1377,4 +1390,3 @@ | ||
| s(:call, nil, :f), | ||
| s(:args, :a, :b, :c, | ||
| s(:block, s(:lasgn, :b, s(:lit, 42)), s(:lasgn, :c, s(:lit, 24)))), | ||
| s(:args, :a, s(:lasgn, :b, s(:lit, 42)), s(:lasgn, :c, s(:lit, 24))), | ||
| s(:array, s(:lvar, :a), s(:lvar, :b), s(:lvar, :c))) | ||
@@ -1389,4 +1401,3 @@ | ||
| s(:call, nil, :f), | ||
| s(:args, :a, :b, :c, :"&d", | ||
| s(:block, s(:lasgn, :b, s(:lit, 42)), s(:lasgn, :c, s(:lit, 24)))), | ||
| s(:args, :a, s(:lasgn, :b, s(:lit, 42)), s(:lasgn, :c, s(:lit, 24)), :"&d"), | ||
| s(:array, s(:lvar, :a), s(:lvar, :b), s(:lvar, :c), s(:lvar, :d))) | ||
@@ -1423,9 +1434,3 @@ | ||
| s(:call, nil, :f), | ||
| s(:masgn, | ||
| s(:array, | ||
| s(:lasgn, :a), | ||
| s(:masgn, | ||
| s(:array, | ||
| s(:lasgn, :b), | ||
| s(:splat, :c)))))) # TODO: omg this is so horrible | ||
| s(:args, :a, s(:masgn, :b, :"*c"))) | ||
@@ -1462,2 +1467,201 @@ assert_parse rb, pt | ||
| # end | ||
| def test_iter_args_4 | ||
| rb = "f { |a, *b, c| }" | ||
| pt = s(:iter, s(:call, nil, :f), s(:args, :a, :"*b", :c)) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_iter_args_5 | ||
| rb = "f { |a, &b| }" | ||
| pt = s(:iter, s(:call, nil, :f), s(:args, :a, :"&b")) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_iter_args_6 | ||
| rb = "f { |a, b=42, c| }" | ||
| pt = s(:iter, s(:call, nil, :f), s(:args, :a, s(:lasgn, :b, s(:lit, 42)), :c)) | ||
| assert_parse rb, pt | ||
| end | ||
| # In 1.8, block args with an outer set of parens are superfluous. | ||
| # In 1.9, outer set of parens are NOT... they are an explicit extra masgn. | ||
| def test_iter_args_2__19 | ||
| rb = "f { |(a, b)| }" | ||
| pt = s(:iter, s(:call, nil, :f), s(:args, s(:masgn, :a, :b))) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_bug_args__19 | ||
| rb = "f { |(a, b)| d }" | ||
| pt = s(:iter, s(:call, nil, :f), | ||
| s(:args, s(:masgn, :a, :b)), | ||
| s(:call, nil, :d)) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_bug_args_masgn_outer_parens__19 | ||
| rb = "f { |((k, v), i)| }" | ||
| pt = s(:iter, # NOTE: same sexp as test_bug_args_masgn | ||
| s(:call, nil, :f), | ||
| s(:args, s(:masgn, s(:masgn, :k, :v), :i))) | ||
| assert_parse rb, pt.dup | ||
| end | ||
| def test_iter_args_7_1 | ||
| rb = "f { |a = 42, *b| }" | ||
| pt = s(:iter, s(:call, nil, :f), | ||
| s(:args, s(:lasgn, :a, s(:lit, 42)), :"*b")) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_iter_args_7_2 | ||
| rb = "f { |a = 42, *b, &c| }" | ||
| pt = s(:iter, s(:call, nil, :f), | ||
| s(:args, s(:lasgn, :a, s(:lit, 42)), :"*b", :"&c")) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_iter_args_8_1 | ||
| rb = "f { |a = 42, *b, c| }" | ||
| pt = s(:iter, s(:call, nil, :f), | ||
| s(:args, s(:lasgn, :a, s(:lit, 42)), :"*b", :c)) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_iter_args_8_2 | ||
| rb = "f { |a = 42, *b, c, &d| }" | ||
| pt = s(:iter, s(:call, nil, :f), | ||
| s(:args, s(:lasgn, :a, s(:lit, 42)), :"*b", :c, :"&d")) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_iter_args_9_1 | ||
| rb = "f { |a = 42, b| }" | ||
| pt = s(:iter, s(:call, nil, :f), | ||
| s(:args, s(:lasgn, :a, s(:lit, 42)), :b)) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_iter_args_9_2 | ||
| rb = "f { |a = 42, b, &c| }" | ||
| pt = s(:iter, s(:call, nil, :f), | ||
| s(:args, s(:lasgn, :a, s(:lit, 42)), :b, :"&c")) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_iter_args_10_1 | ||
| rb = "f { |a, b = 42, *c| }" | ||
| pt = s(:iter, s(:call, nil, :f), | ||
| s(:args, :a, s(:lasgn, :b, s(:lit, 42)), :"*c")) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_iter_args_10_2 | ||
| rb = "f { |a, b = 42, *c, &d| }" | ||
| pt = s(:iter, s(:call, nil, :f), | ||
| s(:args, :a, s(:lasgn, :b, s(:lit, 42)), :"*c", :"&d")) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_iter_args_11_1 | ||
| rb = "f { |a, b = 42, *c, d| }" | ||
| pt = s(:iter, s(:call, nil, :f), | ||
| s(:args, :a, s(:lasgn, :b, s(:lit, 42)), :"*c", :d)) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_iter_args_11_2 | ||
| rb = "f { |a, b = 42, *c, d, &e| }" | ||
| pt = s(:iter, s(:call, nil, :f), | ||
| s(:args, :a, s(:lasgn, :b, s(:lit, 42)), :"*c", :d, :"&e")) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_kill_me_6 | ||
| # | f_marg_list tCOMMA tSTAR f_norm_arg tCOMMA f_marg_list | ||
| rb = "f { |a, (b, *c, d)| }" | ||
| pt = s(:iter, | ||
| s(:call, nil, :f), | ||
| s(:args, :a, s(:masgn, :b, :"*c", :d))) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_kill_me_7 | ||
| # | f_marg_list tCOMMA tSTAR | ||
| rb = "f { |a, (b, *)| }" | ||
| pt = s(:iter, | ||
| s(:call, nil, :f), | ||
| s(:args, :a, s(:masgn, :b, :*))) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_kill_me_8 | ||
| # | f_marg_list tCOMMA tSTAR tCOMMA f_marg_list | ||
| rb = "f { |a, (b, *, c)| }" | ||
| pt = s(:iter, | ||
| s(:call, nil, :f), | ||
| s(:args, :a, s(:masgn, :b, :*, :c))) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_kill_me_9 | ||
| # | tSTAR f_norm_arg | ||
| rb = "f { |a, (*b)| }" | ||
| pt = s(:iter, | ||
| s(:call, nil, :f), | ||
| s(:args, :a, s(:masgn, :"*b"))) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_kill_me_10 | ||
| # | tSTAR f_norm_arg tCOMMA f_marg_list | ||
| rb = "f { |a, (*b, c)| }" | ||
| pt = s(:iter, | ||
| s(:call, nil, :f), | ||
| s(:args, :a, s(:masgn, :"*b", :c))) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_kill_me_11 | ||
| # | tSTAR | ||
| rb = "f { |a, (*)| }" | ||
| pt = s(:iter, | ||
| s(:call, nil, :f), | ||
| s(:args, :a, s(:masgn, :*))) | ||
| assert_parse rb, pt | ||
| end | ||
| def test_kill_me_12 | ||
| # | tSTAR tCOMMA f_marg_list | ||
| rb = "f { |a, (*, b)| }" | ||
| pt = s(:iter, | ||
| s(:call, nil, :f), | ||
| s(:args, :a, s(:masgn, :*, :b))) | ||
| assert_parse rb, pt | ||
| end | ||
| end |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet