summaryrefslogtreecommitdiff
path: root/spec/ruby/optional/capi/module_spec.rb
diff options
context:
space:
mode:
authorBenoit Daloze <[email protected]>2022-06-26 14:50:14 +0200
committerBenoit Daloze <[email protected]>2022-06-26 14:50:14 +0200
commitd3d5ef0cca160fca538c7f556c5a6e08df5847e6 (patch)
tree57358b4b9cdd6f429d0383005ac393cb74dd3bff /spec/ruby/optional/capi/module_spec.rb
parentf616e816372d14e605879d2e43c7fbdda29ef837 (diff)
Update to ruby/spec@ab32a1a
Diffstat (limited to 'spec/ruby/optional/capi/module_spec.rb')
-rw-r--r--spec/ruby/optional/capi/module_spec.rb30
1 files changed, 19 insertions, 11 deletions
diff --git a/spec/ruby/optional/capi/module_spec.rb b/spec/ruby/optional/capi/module_spec.rb
index acf4d1fe48..d7c0ab9c52 100644
--- a/spec/ruby/optional/capi/module_spec.rb
+++ b/spec/ruby/optional/capi/module_spec.rb
@@ -252,22 +252,30 @@ describe "CApiModule" do
cls.new.method(:test_method).arity.should == 0
end
+ it "returns the correct arity when argc of the method in class is 1" do
+ @m.rb_define_method_1required(42).should == 42
+ @m.method(:rb_define_method_1required).arity.should == 1
+ end
+
+ it "returns the correct arity when argc of the method in class is 2" do
+ @m.rb_define_method_2required(1, 2).should == 2
+ @m.method(:rb_define_method_2required).arity.should == 2
+ end
+
+ it "defines a method taking variable arguments as a C array if the argument count is -1" do
+ @m.rb_define_method_varargs_1(1, 3, 7, 4).should == [1, 3, 7, 4]
+ end
+
it "returns the correct arity when argc of the method in class is -1" do
- cls = Class.new
- @m.rb_define_method_c_array(cls, "test_method_c_array")
- cls.new.method(:test_method_c_array).arity.should == -1
+ @m.method(:rb_define_method_varargs_1).arity.should == -1
end
- it "returns the correct arity when argc of the method in class is -2" do
- cls = Class.new
- @m.rb_define_method_ruby_array(cls, "test_method_ruby_array")
- cls.new.method(:test_method_ruby_array).arity.should == -1
+ it "defines a method taking variable arguments as a Ruby array if the argument count is -2" do
+ @m.rb_define_method_varargs_2(1, 3, 7, 4).should == [1, 3, 7, 4]
end
- it "returns the correct arity when argc of the method in class is 2" do
- cls = Class.new
- @m.rb_define_method_2required(cls, "test_method_2required")
- cls.new.method(:test_method_2required).arity.should == 2
+ it "returns the correct arity when argc of the method in class is -2" do
+ @m.method(:rb_define_method_varargs_2).arity.should == -1
end
it "defines a method on a module" do