diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-09-05 13:07:28 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2019-09-05 17:47:12 -0700 |
commit | 729de9ee68b868b43375eb4339b2d59f0bb8e7e8 (patch) | |
tree | a3b0267683c7645da6ccff2a2badc4ee7280c3fd /test | |
parent | e220b467ef3faf24140cba572b2d67973391aaa5 (diff) | |
download | ruby-729de9ee68b868b43375eb4339b2d59f0bb8e7e8.tar.gz |
Convert empty keyword hash to required positional argument and warn for method_missing
This is the same as the bmethod, sym proc, and send cases,
where we don't remove the keyword splat, so later code can
move it to a required positional parameter and warn.
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_keyword.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 2a99feb2de..7624e6d386 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -728,8 +728,12 @@ class TestKeywordArguments < Test::Unit::TestCase def c.method_missing(_, args) args end - assert_raise(ArgumentError) { c.m(**{}) } - assert_raise(ArgumentError) { c.m(**kw) } + assert_warn(/The keyword argument is passed as the last hash parameter.* for `method_missing'/m) do + assert_equal(kw, c.m(**{})) + end + assert_warn(/The keyword argument is passed as the last hash parameter.* for `method_missing'/m) do + assert_equal(kw, c.m(**kw)) + end assert_equal(h, c.m(**h)) assert_equal(h, c.m(a: 1)) assert_equal(h2, c.m(**h2)) @@ -751,8 +755,12 @@ class TestKeywordArguments < Test::Unit::TestCase def c.method_missing(_, arg, **args) [arg, args] end - assert_raise(ArgumentError) { c.m(**{}) } - assert_raise(ArgumentError) { c.m(**kw) } + assert_warn(/The keyword argument is passed as the last hash parameter.* for `method_missing'/m) do + assert_equal([kw, kw], c.m(**{})) + end + assert_warn(/The keyword argument is passed as the last hash parameter.* for `method_missing'/m) do + assert_equal([kw, kw], c.m(**kw)) + end assert_warn(/The keyword argument is passed as the last hash parameter.* for `method_missing'/m) do assert_equal([h, kw], c.m(**h)) end |