From 9f1fb0a17febc59356d58cef5e98db61a3c03550 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 10 Jan 2019 08:19:14 +0000 Subject: 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 --- spec/ruby/optional/capi/proc_spec.rb | 40 ++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'spec/ruby/optional/capi') diff --git a/spec/ruby/optional/capi/proc_spec.rb b/spec/ruby/optional/capi/proc_spec.rb index 94c9276c09..bffb32484c 100644 --- a/spec/ruby/optional/capi/proc_spec.rb +++ b/spec/ruby/optional/capi/proc_spec.rb @@ -69,16 +69,18 @@ describe "C-API when calling Proc.new from a C function" do # For example: C -> Ruby <- C -> Ruby means a C function called into Ruby # code which returned to C, then C called into Ruby code again. - # Ruby -> C -> rb_funcall(Proc.new) - it "returns the Proc passed by the Ruby code calling the C function" do - prc = @p.rb_Proc_new(0) { :called } - prc.call.should == :called - end + ruby_version_is ""..."2.7" do + # Ruby -> C -> rb_funcall(Proc.new) + it "returns the Proc passed by the Ruby code calling the C function" do + prc = @p.rb_Proc_new(0) { :called } + prc.call.should == :called + end - # Ruby -> C -> Ruby <- C -> rb_funcall(Proc.new) - it "returns the Proc passed to the Ruby method when the C function calls other Ruby methods before calling Proc.new" do - prc = @p.rb_Proc_new(1) { :called } - prc.call.should == :called + # Ruby -> C -> Ruby <- C -> rb_funcall(Proc.new) + it "returns the Proc passed to the Ruby method when the C function calls other Ruby methods before calling Proc.new" do + prc = @p.rb_Proc_new(1) { :called } + prc.call.should == :called + end end # Ruby -> C -> Ruby -> Proc.new @@ -93,16 +95,18 @@ describe "C-API when calling Proc.new from a C function" do lambda { @p.rb_Proc_new(3) { :called } }.should raise_error(ArgumentError) end - # Ruby -> C -> Ruby -> C (with new block) -> rb_funcall(Proc.new) - it "returns the most recent Proc passed when the Ruby method called the C function" do - prc = @p.rb_Proc_new(4) { :called } - prc.call.should == :calling_with_block - end + ruby_version_is ""..."2.7" do + # Ruby -> C -> Ruby -> C (with new block) -> rb_funcall(Proc.new) + it "returns the most recent Proc passed when the Ruby method called the C function" do + prc = @p.rb_Proc_new(4) { :called } + prc.call.should == :calling_with_block + end - # Ruby -> C -> Ruby -> C (with new block) <- Ruby <- C -> # rb_funcall(Proc.new) - it "returns the Proc passed from the original Ruby call to the C function" do - prc = @p.rb_Proc_new(5) { :called } - prc.call.should == :called + # Ruby -> C -> Ruby -> C (with new block) <- Ruby <- C -> # rb_funcall(Proc.new) + it "returns the Proc passed from the original Ruby call to the C function" do + prc = @p.rb_Proc_new(5) { :called } + prc.call.should == :called + end end # Ruby -> C -> Ruby -> block_given? -- cgit v1.2.3