Skip to content

Commit e76da03

Browse files
author
Nicolas Laurent
committed
[GR-31156] Enable argument forwarding with leading arguments
PullRequest: truffleruby/2699
2 parents 45b21dd + a9d9694 commit e76da03

File tree

5 files changed

+4641
-4626
lines changed

5 files changed

+4641
-4626
lines changed

spec/ruby/language/delegation_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,30 @@ def delegate(...)
3939
end
4040
end
4141
end
42+
43+
ruby_version_is "2.7.3" do
44+
describe "delegation with def(x, ...)" do
45+
it "delegates rest and kwargs" do
46+
a = Class.new(DelegationSpecs::Target)
47+
a.class_eval(<<-RUBY)
48+
def delegate(x, ...)
49+
target(...)
50+
end
51+
RUBY
52+
53+
a.new.delegate(0, 1, b: 2).should == [[1], {b: 2}]
54+
end
55+
56+
it "delegates block" do
57+
a = Class.new(DelegationSpecs::Target)
58+
a.class_eval(<<-RUBY)
59+
def delegate_block(x, ...)
60+
target_block(...)
61+
end
62+
RUBY
63+
64+
a.new.delegate_block(0, 1, b: 2) { |x| x }.should == [{b: 2}, [1]]
65+
end
66+
67+
end
68+
end

0 commit comments

Comments
 (0)