summaryrefslogtreecommitdiff
path: root/test/ruby/test_keyword.rb
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-16 15:59:16 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-16 15:59:16 +0000
commit5a2f6a4af8a4b1082207979e2913c681ad6ea1bb (patch)
treebb4eb2fa18aa181fa578499312cfec474f929251 /test/ruby/test_keyword.rb
parent12285fc1094bcbe290a8a12555f175c1eb41c88d (diff)
merge revision(s) r45724: [Backport #9776]
* compile.c (compile_array_): make copy a first hash not to modify the argument itself. keyword splat should be non-destructive. [ruby-core:62161] [Bug #9776] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@46451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_keyword.rb')
-rw-r--r--test/ruby/test_keyword.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index f6b4048d61..2ebc298020 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -439,6 +439,19 @@ class TestKeywordArguments < Test::Unit::TestCase
assert_equal([1, 2, 1, [], {:f=>5}, 2, {}], a.new.foo(1, 2, f:5), bug8993)
end
+ def test_splat_keyword_nondestructive
+ bug9776 = '[ruby-core:62161] [Bug #9776]'
+
+ h = {a: 1}
+ assert_equal({a:1, b:2}, {**h, b:2})
+ assert_equal({a:1}, h, bug9776)
+
+ pr = proc {|**opt| next opt}
+ assert_equal({a: 1}, pr.call(**h))
+ assert_equal({a: 1, b: 2}, pr.call(**h, b: 2))
+ assert_equal({a: 1}, h, bug9776)
+ end
+
def test_gced_object_in_stack
bug8964 = '[ruby-dev:47729] [Bug #8964]'
assert_normal_exit %q{