Skip to content

Commit 2334c2b

Browse files
committed
[GR-19220] Add spec for arity in C-ext methods (#2270)
PullRequest: truffleruby/2440
2 parents b947a6d + 479bd4b commit 2334c2b

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

spec/ruby/optional/capi/module_spec.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,23 @@ def method_to_be_aliased
246246
cls.new.test_method.should == :test_method
247247
end
248248

249+
it "returns the correct arity of the method in class" do
250+
cls = Class.new
251+
@m.rb_define_method(cls, "test_method")
252+
cls.new.method(:test_method).arity.should == 0
253+
end
254+
249255
it "defines a method on a module" do
250256
mod = Module.new
251257
@m.rb_define_method(mod, "test_method")
252258
mod.should have_instance_method(:test_method)
253259
end
260+
261+
it "returns the correct arity of the method in module" do
262+
mod = Module.new
263+
@m.rb_define_method(mod, "test_method")
264+
mod.instance_method(:test_method).arity.should == 0
265+
end
254266
end
255267

256268
describe "rb_define_module_function" do
@@ -263,12 +275,23 @@ def method_to_be_aliased
263275
@mod.test_module_function.should == :test_method
264276
end
265277

278+
it "returns the correct arity of the module function" do
279+
@mod.method(:test_module_function).arity.should == 0
280+
end
281+
266282
it "defines a private instance method" do
267283
cls = Class.new
268284
cls.include(@mod)
269285

270286
cls.should have_private_instance_method(:test_module_function)
271287
end
288+
289+
it "returns the correct arity for private instance method" do
290+
cls = Class.new
291+
cls.include(@mod)
292+
293+
@mod.instance_method(:test_module_function).arity.should == 0
294+
end
272295
end
273296

274297
describe "rb_define_private_method" do
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fails:CApiModule rb_define_method returns the correct arity of the method in class
2+
fails:CApiModule rb_define_method returns the correct arity of the method in module
3+
fails:CApiModule rb_define_module_function returns the correct arity of the module function
4+
fails:CApiModule rb_define_module_function returns the correct arity for private instance method

0 commit comments

Comments
 (0)