summaryrefslogtreecommitdiff
path: root/test/ripper
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2019-04-24 10:34:02 -0700
committerJeremy Evans <code@jeremyevans.net>2019-08-30 12:39:31 -0700
commit4d64693c703edbccc5b155072276ce7b8c3becdb (patch)
tree423588954efc5b642fd1748984284df1591ca7d4 /test/ripper
parent6a9ce1fea89bc5c6518dd6bb7ff3b824a9321976 (diff)
downloadruby-4d64693c703edbccc5b155072276ce7b8c3becdb.tar.gz
Make ripper support **nil syntax
The on_params hook will use :nil as the keyword rest argument. There is a new on_nokw_param hook as well. This fixes a type issue in the previous code, where an ID was passed where a VALUE was the declared type. The symbol :nil is passed instead of the id.
Diffstat (limited to 'test/ripper')
-rw-r--r--test/ripper/test_parser_events.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb
index 59d4ad3987..1bae1e31ad 100644
--- a/test/ripper/test_parser_events.rb
+++ b/test/ripper/test_parser_events.rb
@@ -944,6 +944,10 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
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
+ thru_params = false
+ parse('a {|**nil|}', :on_params) {|_, *v| thru_params = true; arg = v}
+ assert_equal true, thru_params
+ assert_equal [nil, nil, nil, nil, nil, :nil, nil], arg
end
def test_params_mlhs
@@ -1153,6 +1157,12 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
assert_equal "x", thru_kwrest
end
+ def test_nokw_param
+ thru_nokw = false
+ parse('def a(**nil) end', :on_nokw_param) {|n, val| thru_nokw = val}
+ assert_equal nil, thru_nokw
+ end
+
def test_retry
thru_retry = false
parse('retry', :on_retry) {thru_retry = true}