Project

General

Profile

Feature #7609 ยป singleton_class_p.patch

nobu (Nobuyoshi Nakada), 12/23/2012 05:48 PM

View differences:

object.c
return rb_cvar_defined(obj, id);
}
static VALUE
rb_mod_singleton_p(VALUE klass)
{
if (RB_TYPE_P(klass, T_CLASS) && FL_TEST(klass, FL_SINGLETON))
return Qtrue;
return Qfalse;
}
static struct conv_method_tbl {
const char *method;
ID id;
......
rb_define_method(rb_cModule, "class_variable_defined?", rb_mod_cvar_defined, 1);
rb_define_method(rb_cModule, "public_constant", rb_mod_public_constant, -1); /* in variable.c */
rb_define_method(rb_cModule, "private_constant", rb_mod_private_constant, -1); /* in variable.c */
rb_define_method(rb_cModule, "singleton_class?", rb_mod_singleton_p, 0);
rb_define_method(rb_cClass, "allocate", rb_obj_alloc, 0);
rb_define_method(rb_cClass, "new", rb_class_new_instance, -1);
test/ruby/test_class.rb
EOF
end
end
def test_singleton_class_p
assert_predicate(self.singleton_class, :singleton_class?)
assert_not_predicate(self.class, :singleton_class?)
end
end
    (1-1/1)