From 6f9f8d2ef7d9c19e39194e6914e4cf39eaa5d473 Mon Sep 17 00:00:00 2001 From: mame Date: Thu, 30 May 2013 10:50:41 +0000 Subject: * vm_insnhelper.c (vm_callee_setup_keyword_arg, vm_callee_setup_arg_complex): consider a hash argument for keyword only when the number of arguments is more than the expected mandatory parameters. [ruby-core:53199] [ruby-trunk - Bug #8040] * test/ruby/test_keyword.rb: update a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40992 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_keyword.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 7443937942..ed1f79cfd3 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -22,7 +22,6 @@ class TestKeywordArguments < Test::Unit::TestCase def test_f2 assert_equal([:xyz, "foo", 424242], f2(:xyz)) - assert_raise(ArgumentError) { f2({}) } # [ruby-dev:46712] [Bug #7529] assert_equal([{"bar"=>42}, "foo", 424242], f2("bar"=>42)) end @@ -379,4 +378,15 @@ class TestKeywordArguments < Test::Unit::TestCase end assert_equal({:bar=>"x"}, a.new.foo(bar: "x"), bug8416) end + + def test_precedence_of_keyword_arguments + bug8040 = '[ruby-core:53199] [Bug #8040]' + a = Class.new do + def foo(x, **h) + [x, h] + end + end + assert_equal([{}, {}], a.new.foo({})) + assert_equal([{}, {:bar=>"x"}], a.new.foo({}, bar: "x")) + end end -- cgit v1.2.3