aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/language
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-10 08:19:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-10 08:19:14 +0000
commit9f1fb0a17febc59356d58cef5e98db61a3c03550 (patch)
tree14c3bf6cd585b859d030ec8d41e6b6e16b0e01e7 /spec/ruby/language
parentec336fb40e4df0c8615e584fbefb5e9e572cb9ec (diff)
downloadruby-9f1fb0a17febc59356d58cef5e98db61a3c03550.tar.gz
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
Diffstat (limited to 'spec/ruby/language')
-rw-r--r--spec/ruby/language/lambda_spec.rb27
1 files changed, 19 insertions, 8 deletions
diff --git a/spec/ruby/language/lambda_spec.rb b/spec/ruby/language/lambda_spec.rb
index 3934a2bd91..7114a38e5c 100644
--- a/spec/ruby/language/lambda_spec.rb
+++ b/spec/ruby/language/lambda_spec.rb
@@ -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/)
-
- implicit_lambda.lambda?.should be_true
- implicit_lambda.call.should == 1
+ 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
+ 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