diff options
author | Benoit Daloze <eregontp@gmail.com> | 2021-03-27 13:02:41 +0100 |
---|---|---|
committer | Benoit Daloze <eregontp@gmail.com> | 2021-03-27 13:02:41 +0100 |
commit | 95d9fe9538441eb57ee6752aa1c5088fc6608e34 (patch) | |
tree | 9a0bb070fd8042b83470f7a0bf9cd462c919c7c0 /spec/ruby/optional/capi/ext | |
parent | 44736a6b7a2b3475db2d05187f33e3c1a7b4b4e5 (diff) |
Update to ruby/spec@fd6eddd
Diffstat (limited to 'spec/ruby/optional/capi/ext')
-rw-r--r-- | spec/ruby/optional/capi/ext/kernel_spec.c | 9 | ||||
-rw-r--r-- | spec/ruby/optional/capi/ext/module_spec.c | 31 |
2 files changed, 40 insertions, 0 deletions
diff --git a/spec/ruby/optional/capi/ext/kernel_spec.c b/spec/ruby/optional/capi/ext/kernel_spec.c index a1960a2fe7..bbfeb198b7 100644 --- a/spec/ruby/optional/capi/ext/kernel_spec.c +++ b/spec/ruby/optional/capi/ext/kernel_spec.c @@ -191,6 +191,14 @@ static VALUE kernel_spec_rb_protect_yield(VALUE self, VALUE obj, VALUE ary) { return res; } +static VALUE kernel_spec_rb_protect_errinfo(VALUE self, VALUE obj, VALUE ary) { + int status = 0; + VALUE res = rb_protect(rb_yield, obj, &status); + rb_ary_store(ary, 0, INT2NUM(23)); + rb_ary_store(ary, 1, res); + return rb_errinfo(); +} + static VALUE kernel_spec_rb_protect_null_status(VALUE self, VALUE obj) { return rb_protect(rb_yield, obj, NULL); } @@ -345,6 +353,7 @@ void Init_kernel_spec(void) { rb_define_method(cls, "rb_rescue", kernel_spec_rb_rescue, 4); rb_define_method(cls, "rb_rescue2", kernel_spec_rb_rescue2, -1); rb_define_method(cls, "rb_protect_yield", kernel_spec_rb_protect_yield, 2); + rb_define_method(cls, "rb_protect_errinfo", kernel_spec_rb_protect_errinfo, 2); rb_define_method(cls, "rb_protect_null_status", kernel_spec_rb_protect_null_status, 1); rb_define_method(cls, "rb_eval_string_protect", kernel_spec_rb_eval_string_protect, 2); rb_define_method(cls, "rb_catch", kernel_spec_rb_catch, 2); diff --git a/spec/ruby/optional/capi/ext/module_spec.c b/spec/ruby/optional/capi/ext/module_spec.c index 3c8455a942..7475994fa1 100644 --- a/spec/ruby/optional/capi/ext/module_spec.c +++ b/spec/ruby/optional/capi/ext/module_spec.c @@ -9,6 +9,18 @@ static VALUE module_specs_test_method(VALUE self) { return ID2SYM(rb_intern("test_method")); } +static VALUE module_specs_test_method_2required(VALUE self, VALUE arg1, VALUE arg2) { + return ID2SYM(rb_intern("test_method_2required")); +} + +static VALUE module_specs_test_method_c_array(int argc, VALUE *argv, VALUE self) { + return ID2SYM(rb_intern("test_method_c_array")); +} + +static VALUE module_specs_test_method_ruby_array(VALUE self, VALUE args) { + return ID2SYM(rb_intern("test_method_ruby_array")); +} + static VALUE module_specs_const_defined(VALUE self, VALUE klass, VALUE id) { return rb_const_defined(klass, SYM2ID(id)) ? Qtrue : Qfalse; } @@ -76,6 +88,21 @@ static VALUE module_specs_rb_define_method(VALUE self, VALUE cls, VALUE str_name return Qnil; } +static VALUE module_specs_rb_define_method_2required(VALUE self, VALUE cls, VALUE str_name) { + rb_define_method(cls, RSTRING_PTR(str_name), module_specs_test_method_2required, 2); + return Qnil; +} + +static VALUE module_specs_rb_define_method_c_array(VALUE self, VALUE cls, VALUE str_name) { + rb_define_method(cls, RSTRING_PTR(str_name), module_specs_test_method_c_array, -1); + return Qnil; +} + +static VALUE module_specs_rb_define_method_ruby_array(VALUE self, VALUE cls, VALUE str_name) { + rb_define_method(cls, RSTRING_PTR(str_name), module_specs_test_method_ruby_array, -2); + return Qnil; +} + static VALUE module_specs_rb_define_module_function(VALUE self, VALUE cls, VALUE str_name) { rb_define_module_function(cls, RSTRING_PTR(str_name), module_specs_test_method, 0); return Qnil; @@ -132,6 +159,10 @@ void Init_module_spec(void) { module_specs_rb_define_global_function, 1); rb_define_method(cls, "rb_define_method", module_specs_rb_define_method, 2); + rb_define_method(cls, "rb_define_method_2required", module_specs_rb_define_method_2required, 2); + rb_define_method(cls, "rb_define_method_c_array", module_specs_rb_define_method_c_array, 2); + rb_define_method(cls, "rb_define_method_ruby_array", module_specs_rb_define_method_ruby_array, 2); + rb_define_method(cls, "rb_define_module_function", module_specs_rb_define_module_function, 2); |