mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
proc.c: proc without block
* proc.c (proc_new): promoted lambda/proc/Proc.new with no block in a method called with a block to a warning/error. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ec336fb40e
commit
9f1fb0a17f
10 changed files with 144 additions and 66 deletions
|
@ -310,14 +310,25 @@ describe "A lambda expression 'lambda { ... }'" do
|
|||
def meth; lambda; end
|
||||
end
|
||||
|
||||
it "can be created" do
|
||||
implicit_lambda = nil
|
||||
-> {
|
||||
implicit_lambda = meth { 1 }
|
||||
}.should complain(/tried to create Proc object without a block/)
|
||||
ruby_version_is ""..."2.7" do
|
||||
it "can be created" do
|
||||
implicit_lambda = nil
|
||||
-> {
|
||||
implicit_lambda = meth { 1 }
|
||||
}.should complain(/tried to create Proc object without a block/)
|
||||
|
||||
implicit_lambda.lambda?.should be_true
|
||||
implicit_lambda.call.should == 1
|
||||
implicit_lambda.lambda?.should be_true
|
||||
implicit_lambda.call.should == 1
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.7" do
|
||||
it "raises ArgumentError" do
|
||||
implicit_lambda = nil
|
||||
-> {
|
||||
meth { 1 }
|
||||
}.should raise_error(ArgumentError, /tried to create Proc object without a block/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue