summaryrefslogtreecommitdiff
path: root/spec/ruby/optional/capi
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/optional/capi
parentec336fb40e4df0c8615e584fbefb5e9e572cb9ec (diff)
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/optional/capi')
-rw-r--r--spec/ruby/optional/capi/proc_spec.rb40
1 files changed, 22 insertions, 18 deletions
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?