diff options
author | Jeremy Evans <code@jeremyevans.net> | 2019-09-27 09:35:51 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2019-09-27 11:21:50 -0700 |
commit | 7814b6c6572446a6b64614e524d13dd423577004 (patch) | |
tree | 125375c31c9b3ca937b90a93d07795e6692c8414 /test/ruby/test_keyword.rb | |
parent | fd0e2141835a0ef98b31d0a6b23924413f8452d3 (diff) |
Correctly issue ArgumentError when calling method that accepts no keywords
If a method accepts no keywords and was called with a keyword, an
ArgumentError was not always issued previously. Force methods that
accept no keywords to go through setup_parameters_complex so that
an ArgumentError is raised if keywords are provided.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/2501
Diffstat (limited to 'test/ruby/test_keyword.rb')
-rw-r--r-- | test/ruby/test_keyword.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 5992434c97..1a445cdf50 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -158,6 +158,19 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([b, [:b]], f12(**h, &b)) end + def f13(a, **nil) + a + end + + def test_f13 + assert_equal(1, f13(1)) + assert_equal(1, f13(1, **{})) + assert_raise(ArgumentError) { f13(a: 1) } + assert_raise(ArgumentError) { f13(1, a: 1) } + assert_raise(ArgumentError) { f13(**{a: 1}) } + assert_raise(ArgumentError) { f13(1, **{a: 1}) } + end + def test_method_parameters assert_equal([[:key, :str], [:key, :num]], method(:f1).parameters); assert_equal([[:req, :x], [:key, :str], [:key, :num]], method(:f2).parameters); |