From e220b467ef3faf24140cba572b2d67973391aaa5 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 5 Sep 2019 13:03:09 -0700 Subject: Convert empty keyword hash to required positional argument and warn for sym procs This is the same as the bmethod and send cases, where we don't remove the keyword splat, so later code can move it to to a a required positional parameter and warn. --- test/ruby/test_keyword.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index c5b9c15ba9..2a99feb2de 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -633,8 +633,12 @@ class TestKeywordArguments < Test::Unit::TestCase def c.m(args) args end - assert_raise(ArgumentError) { :m.to_proc.call(c, **{}) } - assert_raise(ArgumentError) { :m.to_proc.call(c, **kw) } + assert_warn(/The keyword argument is passed as the last hash parameter.* for `m'/m) do + assert_equal(kw, :m.to_proc.call(c, **{})) + end + assert_warn(/The keyword argument is passed as the last hash parameter.* for `m'/m) do + assert_equal(kw, :m.to_proc.call(c, **kw)) + end assert_equal(h, :m.to_proc.call(c, **h)) assert_equal(h, :m.to_proc.call(c, a: 1)) assert_equal(h2, :m.to_proc.call(c, **h2)) @@ -657,8 +661,12 @@ class TestKeywordArguments < Test::Unit::TestCase def c.m(arg, **args) [arg, args] end - assert_raise(ArgumentError) { :m.to_proc.call(c, **{}) } - assert_raise(ArgumentError) { :m.to_proc.call(c, **kw) } + assert_warn(/The keyword argument is passed as the last hash parameter.* for `m'/m) do + assert_equal([kw, kw], :m.to_proc.call(c, **{})) + end + assert_warn(/The keyword argument is passed as the last hash parameter.* for `m'/m) do + assert_equal([kw, kw], :m.to_proc.call(c, **kw)) + end assert_warn(/The keyword argument is passed as the last hash parameter.* for `m'/m) do assert_equal([h, kw], :m.to_proc.call(c, **h)) end -- cgit v1.2.3