parent
6d05967468
commit
ce9beb9d20
Notes:
git
2025-04-09 13:49:37 +00:00
2
class.c
2
class.c
@ -227,7 +227,7 @@ void
|
|||||||
rb_check_inheritable(VALUE super)
|
rb_check_inheritable(VALUE super)
|
||||||
{
|
{
|
||||||
if (!RB_TYPE_P(super, T_CLASS)) {
|
if (!RB_TYPE_P(super, T_CLASS)) {
|
||||||
rb_raise(rb_eTypeError, "superclass must be a Class (%"PRIsVALUE" given)",
|
rb_raise(rb_eTypeError, "superclass must be an instance of Class (given an instance of %"PRIsVALUE")",
|
||||||
rb_obj_class(super));
|
rb_obj_class(super));
|
||||||
}
|
}
|
||||||
if (RBASIC(super)->flags & FL_SINGLETON) {
|
if (RBASIC(super)->flags & FL_SINGLETON) {
|
||||||
|
@ -95,7 +95,7 @@ describe "Class.new" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "raises a TypeError when given a non-Class" do
|
it "raises a TypeError when given a non-Class" do
|
||||||
error_msg = /superclass must be a Class/
|
error_msg = /superclass must be a.*Class/
|
||||||
-> { Class.new("") }.should raise_error(TypeError, error_msg)
|
-> { Class.new("") }.should raise_error(TypeError, error_msg)
|
||||||
-> { Class.new(1) }.should raise_error(TypeError, error_msg)
|
-> { Class.new(1) }.should raise_error(TypeError, error_msg)
|
||||||
-> { Class.new(:symbol) }.should raise_error(TypeError, error_msg)
|
-> { Class.new(:symbol) }.should raise_error(TypeError, error_msg)
|
||||||
|
@ -286,7 +286,7 @@ describe "A class definition extending an object (sclass)" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "raises a TypeError when trying to extend non-Class" do
|
it "raises a TypeError when trying to extend non-Class" do
|
||||||
error_msg = /superclass must be a Class/
|
error_msg = /superclass must be a.* Class/
|
||||||
-> { class TestClass < ""; end }.should raise_error(TypeError, error_msg)
|
-> { class TestClass < ""; end }.should raise_error(TypeError, error_msg)
|
||||||
-> { class TestClass < 1; end }.should raise_error(TypeError, error_msg)
|
-> { class TestClass < 1; end }.should raise_error(TypeError, error_msg)
|
||||||
-> { class TestClass < :symbol; end }.should raise_error(TypeError, error_msg)
|
-> { class TestClass < :symbol; end }.should raise_error(TypeError, error_msg)
|
||||||
|
@ -4068,7 +4068,7 @@ vm_define_class(ID id, rb_num_t flags, VALUE cbase, VALUE super)
|
|||||||
|
|
||||||
if (VM_DEFINECLASS_HAS_SUPERCLASS_P(flags) && !RB_TYPE_P(super, T_CLASS)) {
|
if (VM_DEFINECLASS_HAS_SUPERCLASS_P(flags) && !RB_TYPE_P(super, T_CLASS)) {
|
||||||
rb_raise(rb_eTypeError,
|
rb_raise(rb_eTypeError,
|
||||||
"superclass must be a Class (%"PRIsVALUE" given)",
|
"superclass must be an instance of Class (given an instance of %"PRIsVALUE")",
|
||||||
rb_obj_class(super));
|
rb_obj_class(super));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user