diff options
| author | Koichi Sasada <ko1@atdot.net> | 2023-03-14 03:42:47 +0900 |
|---|---|---|
| committer | Koichi Sasada <ko1@atdot.net> | 2023-03-15 18:05:13 +0900 |
| commit | 6462c1a042fec4017f7e3bf2c13ec6a29efd23d6 (patch) | |
| tree | 01b3c6e3819e91525acce8c68bd0de8931551fe9 /test/ruby | |
| parent | 7fd53eeb46db261bbc20025cdab70096245a5cbe (diff) | |
`Hash#dup` for kwsplat arguments
On `f(*a, **kw)` method calls, a rest keyword parameter is identically
same Hash object is passed and it should make `#dup`ed Hahs.
fix https://bugs.ruby-lang.org/issues/19526
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7507
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_keyword.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 94b5323ab0..ef594bd52e 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -447,6 +447,16 @@ class TestKeywordArguments < Test::Unit::TestCase assert_equal(false, public_send(:yo, **{}).frozen?) assert_equal_not_same(kw, public_send(:yo, **kw)) assert_equal_not_same(h, public_send(:yo, **h)) + + def self.yo(*a, **kw) = kw + assert_equal_not_same kw, yo(**kw) + assert_equal_not_same kw, yo(**kw, **kw) + + singleton_class.send(:remove_method, :yo) + def self.yo(opts) = opts + assert_equal_not_same h, yo(*[], **h) + a = [] + assert_equal_not_same h, yo(*a, **h) end def test_regular_kwsplat |
