summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-26 01:55:34 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-26 01:55:34 +0000
commit37e432b5bf4d873a987738891d86f588e97a53a6 (patch)
tree878c034361d86a25b303d677c1161b7575f64344 /test
parent3bd10c6ee7a4d05e25610690f52efe4557dd8ed2 (diff)
compile.c: non-destructive keyword splat
* 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/trunk@45724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-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 31830dfb2f..5988905138 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{