diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-01-10 08:19:14 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-01-10 08:19:14 +0000 |
commit | 9f1fb0a17febc59356d58cef5e98db61a3c03550 (patch) | |
tree | 14c3bf6cd585b859d030ec8d41e6b6e16b0e01e7 /spec/ruby/core/proc/block_pass_spec.rb | |
parent | ec336fb40e4df0c8615e584fbefb5e9e572cb9ec (diff) | |
download | ruby-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/core/proc/block_pass_spec.rb')
-rw-r--r-- | spec/ruby/core/proc/block_pass_spec.rb | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/spec/ruby/core/proc/block_pass_spec.rb b/spec/ruby/core/proc/block_pass_spec.rb index 282f00b5a8..917a38efac 100644 --- a/spec/ruby/core/proc/block_pass_spec.rb +++ b/spec/ruby/core/proc/block_pass_spec.rb @@ -20,22 +20,39 @@ describe "Proc as a block pass argument" do end end -describe "Proc as an implicit block pass argument" do - def revivify - Proc.new - end +ruby_version_is ""..."2.7" do + describe "Proc as an implicit block pass argument" do + def revivify + Proc.new + end - it "remains the same object if re-vivified by the target method" do - p = Proc.new {} - p2 = revivify(&p) - p.should equal p2 - p.should == p2 + it "remains the same object if re-vivified by the target method" do + p = Proc.new {} + p2 = revivify(&p) + p.should equal p2 + p.should == p2 + end + + it "remains the same object if reconstructed with Proc.new" do + p = Proc.new {} + p2 = Proc.new(&p) + p.should equal p2 + p.should == p2 + end end +end - it "remains the same object if reconstructed with Proc.new" do - p = Proc.new {} - p2 = Proc.new(&p) - p.should equal p2 - p.should == p2 +ruby_version_is "2.7" do + describe "Proc called with no block" do + def revivify + Proc.new + end + + it "raises ArgumentError when called with no block" do + p = Proc.new {} + -> { + revivify(&p) + }.should + end end end |