1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
This commit is contained in:
Benoit Daloze 2020-06-27 15:51:37 +02:00
parent 64d8c0815e
commit b3fa158d1c
35 changed files with 652 additions and 56 deletions

View file

@ -102,6 +102,37 @@ describe "The super keyword" do
c2.new.m(:dump) { :value }.should == :value
end
it "can pass an explicit block" do
c1 = Class.new do
def m(v)
yield(v)
end
end
c2 = Class.new(c1) do
def m(v)
block = -> w { yield(w + 'b') }
super(v, &block)
end
end
c2.new.m('a') { |x| x + 'c' }.should == 'abc'
end
it "can pass no block using &nil" do
c1 = Class.new do
def m(v)
block_given?
end
end
c2 = Class.new(c1) do
def m(v)
super(v, &nil)
end
end
c2.new.m('a') { raise }.should be_false
end
it "uses block argument given to method when used in a block" do
c1 = Class.new do
def m