diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-12-28 01:38:17 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-12-28 01:52:18 +0900 |
commit | c8010fcec016ee89aa0c45fe31094b2db0023e5c (patch) | |
tree | 3b3a20a8fca8968ee07f6094b666162d748eaae2 /test/ruby/test_keyword.rb | |
parent | cc055d4d3fc4a3999766b17a2c9f7cd968be1118 (diff) |
Dup kwrest hash when merging other keyword arguments [Bug #17481]
Diffstat (limited to 'test/ruby/test_keyword.rb')
-rw-r--r-- | test/ruby/test_keyword.rb | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 8ec0636d5c..de367e6a30 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -3681,6 +3681,25 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal([42, {:bar=>"x"}], b.new.foo(42), bug8236) end + def test_super_with_keyword_kwrest + base = Class.new do + def foo(**h) + h + end + end + a = Class.new(base) do + attr_reader :h + def foo(a:, b:, **h) + @h = h + super + end + end + + o = a.new + assert_equal({a: 1, b: 2, c: 3}, o.foo(a: 1, b: 2, c: 3)) + assert_equal({c: 3}, o.h) + end + def test_zsuper_only_named_kwrest bug8416 = '[ruby-core:55033] [Bug #8416]' base = Class.new do @@ -3689,11 +3708,15 @@ class TestKeywordArguments < Test::Unit::TestCase end end a = Class.new(base) do + attr_reader :h def foo(**h) + @h = h super end end - assert_equal({:bar=>"x"}, a.new.foo(bar: "x"), bug8416) + o = a.new + assert_equal({:bar=>"x"}, o.foo(bar: "x"), bug8416) + assert_equal({:bar=>"x"}, o.h) end def test_zsuper_only_anonymous_kwrest |