Skip to content

Commit e695ce6

Browse files
headiuseregon
authored andcommitted
Add spec for non-kwargs hash passed through delegation
See jruby/jruby#9462
1 parent 83345b2 commit e695ce6

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

language/delegation_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@ def delegate(...)
5959

6060
a.new.delegate(1, b: 2).should == Range.new([[], {}, nil], nil, true)
6161
end
62+
63+
it "passes non-keyword trailing hash through without modification" do
64+
a = Class.new(DelegationSpecs::Target)
65+
a.class_eval(<<-RUBY)
66+
def delegate(...)
67+
target_single(...)
68+
end
69+
RUBY
70+
71+
h = {a:1}
72+
h.freeze
73+
h2 = a.new.delegate(h)
74+
h2.should.equal?(h)
75+
end
6276
end
6377

6478
describe "delegation with def(x, ...)" do

language/fixtures/delegation.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,9 @@ def target(*args, **kwargs, &block)
77
def target_block(*args, **kwargs)
88
yield [kwargs, args]
99
end
10+
11+
def target_single(arg)
12+
arg
13+
end
1014
end
1115
end

0 commit comments

Comments
 (0)