Add rb_prepend_module C API spec

Cover the public C API so missing implementations are detected.
This commit is contained in:
Nobuyoshi Nakada 2026-08-02 12:41:59 +09:00
parent 62eaaae3c2
commit 79fa2bcf72
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2026-08-02 04:45:34 +00:00
2 changed files with 17 additions and 0 deletions

View File

@ -149,6 +149,17 @@ describe "C-API Class function" do
end
end
describe "rb_prepend_module" do
it "prepends a module into a class" do
klass = Class.new
mod = Module.new
@s.rb_prepend_module(klass, mod)
klass.ancestors[0, 2].should == [mod, klass]
end
end
describe "rb_define_attr" do
before :each do
@a = CApiClassSpecs::Attr.new

View File

@ -144,6 +144,11 @@ static VALUE class_spec_include_module(VALUE self, VALUE klass, VALUE module) {
return klass;
}
static VALUE class_spec_prepend_module(VALUE self, VALUE klass, VALUE module) {
rb_prepend_module(klass, module);
return klass;
}
void Init_class_spec(void) {
VALUE cls = rb_define_class("CApiClassSpecs", rb_cObject);
rb_define_method(cls, "define_call_super_method", class_spec_define_call_super_method, 2);
@ -173,6 +178,7 @@ void Init_class_spec(void) {
rb_define_method(cls, "rb_define_class_id_under", class_spec_rb_define_class_id_under, 3);
rb_define_method(cls, "rb_define_class_variable", class_spec_define_class_variable, 3);
rb_define_method(cls, "rb_include_module", class_spec_include_module, 2);
rb_define_method(cls, "rb_prepend_module", class_spec_prepend_module, 2);
}
#ifdef __cplusplus