1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/spec/ruby/language/delegation_spec.rb
Kazuhiro NISHIYAMA fcd605020b
Fix a typo
2020-03-07 13:49:28 +09:00

41 lines
999 B
Ruby

require_relative '../spec_helper'
require_relative 'fixtures/delegation'
ruby_version_is "2.7" do
describe "delegation with def(...)" do
it "delegates rest and kwargs" do
a = Class.new(DelegationSpecs::Target)
a.class_eval(<<-RUBY)
def delegate(...)
target(...)
end
RUBY
a.new.delegate(1, b: 2).should == [[1], {b: 2}]
end
it "delegates block" do
a = Class.new(DelegationSpecs::Target)
a.class_eval(<<-RUBY)
def delegate_block(...)
target_block(...)
end
RUBY
a.new.delegate_block(1, b: 2) { |x| x }.should == [{b: 2}, [1]]
end
it "parses as open endless Range when brackets are omitted" do
a = Class.new(DelegationSpecs::Target)
suppress_warning do
a.class_eval(<<-RUBY)
def delegate(...)
target ...
end
RUBY
end
a.new.delegate(1, b: 2).should == Range.new([[], {}], nil, true)
end
end
end