summaryrefslogtreecommitdiff
path: root/test/ruby/test_keyword.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_keyword.rb')
-rw-r--r--test/ruby/test_keyword.rb26
1 files changed, 20 insertions, 6 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index ef594bd52e..9aca787dff 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -237,16 +237,16 @@ class TestKeywordArguments < Test::Unit::TestCase
assert_equal(true, Hash.ruby2_keywords_hash?(marked))
end
+ def assert_equal_not_same(kw, res)
+ assert_instance_of(Hash, res)
+ assert_equal(kw, res)
+ assert_not_same(kw, res)
+ end
+
def test_keyword_splat_new
kw = {}
h = {a: 1}
- def self.assert_equal_not_same(kw, res)
- assert_instance_of(Hash, res)
- assert_equal(kw, res)
- assert_not_same(kw, res)
- end
-
def self.yo(**kw) kw end
m = method(:yo)
assert_equal(false, yo(**{}).frozen?)
@@ -459,6 +459,20 @@ class TestKeywordArguments < Test::Unit::TestCase
assert_equal_not_same h, yo(*a, **h)
end
+ def test_keyword_splat_to_non_keyword_method
+ h = {a: 1}.freeze
+
+ def self.yo(kw) kw end
+ assert_equal_not_same(h, yo(**h))
+ assert_equal_not_same(h, method(:yo).(**h))
+ assert_equal_not_same(h, :yo.to_proc.(self, **h))
+
+ def self.yoa(*kw) kw[0] end
+ assert_equal_not_same(h, yoa(**h))
+ assert_equal_not_same(h, method(:yoa).(**h))
+ assert_equal_not_same(h, :yoa.to_proc.(self, **h))
+ end
+
def test_regular_kwsplat
kw = {}
h = {:a=>1}