Skip to content

Commit 3707dcc

Browse files
headiusenebo
authored andcommitted
Add spec for ruby2 kwargs passed as normal argument
JRuby was overzealous in duping kwargs hashes, losing the ruby2_keywords_hash bit in the process. This backs off duping and only does so if receiving ruby2 kwargs for a modern kwargs method. See jruby#8976
1 parent b079ea1 commit 3707dcc

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

spec/ruby/language/keyword_arguments_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,20 @@ def m(*a)
8686
m(*[], 42, **{}).should == [42]
8787
end
8888

89+
context "marked as ruby2_keywords_hash" do
90+
it "is not copied when passed as a positional argument" do
91+
h = Hash.ruby2_keywords_hash(a:1)
92+
93+
def bar(a)
94+
a
95+
end
96+
97+
h2 = bar(h)
98+
h2.should equal(h)
99+
Hash.ruby2_keywords_hash?(h).should == true
100+
end
101+
end
102+
89103
context "**" do
90104
ruby_version_is "3.3" do
91105
it "copies a non-empty Hash for a method taking (*args)" do

0 commit comments

Comments
 (0)