mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
add test for rb_define_method_id
was missing.
This commit is contained in:
parent
3c3eb418f9
commit
16592d6b69
1 changed files with 56 additions and 0 deletions
|
@ -393,6 +393,62 @@ namespace test_rb_define_method {
|
|||
}
|
||||
}
|
||||
|
||||
namespace test_rb_define_method_id {
|
||||
static VALUE
|
||||
m1(VALUE, VALUE)
|
||||
{
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
m2(VALUE, VALUE, VALUE)
|
||||
{
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
ma(VALUE, VALUE)
|
||||
{
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
mv(int, VALUE*, VALUE)
|
||||
{
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
VALUE
|
||||
test(VALUE self)
|
||||
{
|
||||
// No cast
|
||||
rb_define_method_id(self, rb_intern("m1"), m1, 1);
|
||||
rb_define_method_id(self, rb_intern("m2"), m2, 2);
|
||||
rb_define_method_id(self, rb_intern("ma"), ma, -2);
|
||||
rb_define_method_id(self, rb_intern("mv"), mv, -1);
|
||||
|
||||
// Cast by RUBY_METHOD_FUNC
|
||||
rb_define_method_id(self, rb_intern("m1"), RUBY_METHOD_FUNC(m1), 1);
|
||||
rb_define_method_id(self, rb_intern("m2"), RUBY_METHOD_FUNC(m2), 2);
|
||||
rb_define_method_id(self, rb_intern("ma"), RUBY_METHOD_FUNC(ma), -2);
|
||||
rb_define_method_id(self, rb_intern("mv"), RUBY_METHOD_FUNC(mv), -1);
|
||||
|
||||
// Explicit cast instead of RUBY_METHOD_FUNC
|
||||
rb_define_method_id(self, rb_intern("m1"), (VALUE (*)(...))(m1), 1);
|
||||
rb_define_method_id(self, rb_intern("m2"), (VALUE (*)(...))(m2), 2);
|
||||
rb_define_method_id(self, rb_intern("ma"), (VALUE (*)(...))(ma), -2);
|
||||
rb_define_method_id(self, rb_intern("mv"), (VALUE (*)(...))(mv), -1);
|
||||
|
||||
// rb_f_notimplement
|
||||
rb_define_method_id(self, rb_intern("m1"), rb_f_notimplement, 1);
|
||||
rb_define_method_id(self, rb_intern("m2"), rb_f_notimplement, 2);
|
||||
rb_define_method_id(self, rb_intern("ma"), rb_f_notimplement, -2);
|
||||
rb_define_method_id(self, rb_intern("mv"), rb_f_notimplement, -1);
|
||||
|
||||
return self;
|
||||
}
|
||||
}
|
||||
|
||||
namespace test_rb_define_module_function {
|
||||
static VALUE
|
||||
m1(VALUE, VALUE)
|
||||
|
|
Loading…
Add table
Reference in a new issue