summaryrefslogtreecommitdiff
path: root/test/ruby/test_keyword.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-07 03:09:28 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-07 03:09:28 +0000
commit8f1be270179f771b517d551fe1ce3d12234f0324 (patch)
tree2fa87b560517795a590f4f98bdd5f7d6e11ba4dc /test/ruby/test_keyword.rb
parent04d244642d0a42aa0bfe3f8ed4afa0e0d8744254 (diff)
vm_insnhelper.c: keyrest should not overwrite rest arg
* vm_insnhelper.c (vm_callee_setup_arg_complex, vm_yield_setup_block_args): set keyrest hash after making rest array, so that the last element will not be overwritten. [ruby-core:51278] [Bug #7665] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_keyword.rb')
-rw-r--r--test/ruby/test_keyword.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index a8a609696a..8fe69b44fb 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -255,4 +255,15 @@ class TestKeywordArguments < Test::Unit::TestCase
assert_equal(["foo", 111111], m1(num: 111111, &blk))
assert_equal(["bar", 111111], m1(str: "bar", num: 111111, &blk))
end
+
+ def rest_keyrest(*args, **opt)
+ return *args, opt
+ end
+
+ def test_rest_keyrest
+ bug7665 = '[ruby-core:51278]'
+ expect = [*%w[foo bar], {zzz: 42}]
+ assert_equal(expect, rest_keyrest(*expect), bug7665)
+ assert_equal(expect, proc {|*args, **opt| next *args, opt}.call(*expect), bug7665)
+ end
end