mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
spec: suppress deprecations of "lambda(&proc_block)" pattern
This commit is contained in:
parent
efbef729b2
commit
7ef5226520
3 changed files with 21 additions and 11 deletions
|
@ -27,8 +27,10 @@ describe "Kernel.lambda" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "creates a lambda-style Proc if given a literal block via Kernel.public_send" do
|
it "creates a lambda-style Proc if given a literal block via Kernel.public_send" do
|
||||||
l = Kernel.public_send(:lambda) { 42 }
|
suppress_warning do
|
||||||
l.lambda?.should be_true
|
l = Kernel.public_send(:lambda) { 42 }
|
||||||
|
l.lambda?.should be_true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the passed Proc if given an existing Proc" do
|
it "returns the passed Proc if given an existing Proc" do
|
||||||
|
@ -39,11 +41,13 @@ describe "Kernel.lambda" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "creates a lambda-style Proc when called with zsuper" do
|
it "creates a lambda-style Proc when called with zsuper" do
|
||||||
l = KernelSpecs::LambdaSpecs::ForwardBlockWithZSuper.new.lambda { 42 }
|
suppress_warning do
|
||||||
l.lambda?.should be_true
|
l = KernelSpecs::LambdaSpecs::ForwardBlockWithZSuper.new.lambda { 42 }
|
||||||
l.call.should == 42
|
l.lambda?.should be_true
|
||||||
|
l.call.should == 42
|
||||||
|
|
||||||
lambda { l.call(:extra) }.should raise_error(ArgumentError)
|
lambda { l.call(:extra) }.should raise_error(ArgumentError)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the passed Proc if given an existing Proc through super" do
|
it "returns the passed Proc if given an existing Proc through super" do
|
||||||
|
|
|
@ -4,6 +4,8 @@ describe :kernel_lambda, shared: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises an ArgumentError when no block is given" do
|
it "raises an ArgumentError when no block is given" do
|
||||||
-> { send(@method) }.should raise_error(ArgumentError)
|
suppress_warning do
|
||||||
|
-> { send(@method) }.should raise_error(ArgumentError)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -348,7 +348,9 @@ describe "A lambda expression 'lambda { ... }'" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "requires a block" do
|
it "requires a block" do
|
||||||
lambda { lambda }.should raise_error(ArgumentError)
|
suppress_warning do
|
||||||
|
lambda { lambda }.should raise_error(ArgumentError)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "may include a rescue clause" do
|
it "may include a rescue clause" do
|
||||||
|
@ -375,9 +377,11 @@ describe "A lambda expression 'lambda { ... }'" do
|
||||||
ruby_version_is "2.7" do
|
ruby_version_is "2.7" do
|
||||||
it "raises ArgumentError" do
|
it "raises ArgumentError" do
|
||||||
implicit_lambda = nil
|
implicit_lambda = nil
|
||||||
-> {
|
suppress_warning do
|
||||||
meth { 1 }
|
-> {
|
||||||
}.should raise_error(ArgumentError, /tried to create Proc object without a block/)
|
meth { 1 }
|
||||||
|
}.should raise_error(ArgumentError, /tried to create Proc object without a block/)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue