diff options
Diffstat (limited to 'test/ripper')
-rw-r--r-- | test/ripper/dummyparser.rb | 4 | ||||
-rw-r--r-- | test/ripper/test_parser_events.rb | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/test/ripper/dummyparser.rb b/test/ripper/dummyparser.rb index 6de7e19013..4261ab5e82 100644 --- a/test/ripper/dummyparser.rb +++ b/test/ripper/dummyparser.rb @@ -153,6 +153,10 @@ class DummyParser < Ripper "*#{var}" end + def on_kwrest_param(var) + "**#{var}" + end + def on_blockarg(var) "&#{var}" end diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb index c9189ee7a8..03580107a0 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -893,7 +893,7 @@ class TestRipper::ParserEvents < Test::Unit::TestCase thru_params = false parse('a {|**x|}', :on_params) {|_, *v| thru_params = true; arg = v} assert_equal true, thru_params - assert_equal [nil, nil, nil, nil, nil, "x", nil], arg + assert_equal [nil, nil, nil, nil, nil, "**x", nil], arg end def test_params_mlhs @@ -1079,6 +1079,15 @@ class TestRipper::ParserEvents < Test::Unit::TestCase assert_equal true, thru_rest_param end + def test_kwrest_param + thru_kwrest = false + parse('def a(**) end', :on_kwrest_param) {|n, val| thru_kwrest = val} + assert_equal nil, thru_kwrest + thru_kwrest = false + parse('def a(**x) end', :on_kwrest_param) {|n, val| thru_kwrest = val} + assert_equal "x", thru_kwrest + end + def test_retry thru_retry = false parse('retry', :on_retry) {thru_retry = true} |