Project

General

Profile

Bug #8297 ยป singleton-class-class-variable-lookup-8297.patch

jeremyevans0 (Jeremy Evans), 08/10/2019 04:29 AM

View differences:

test/ruby/test_variable.rb
end
end
def test_singleton_class_included_class_variable
c = Class.new
c.extend(Olympians)
assert_empty(c.singleton_class.class_variables)
assert_raise(NameError){ c.singleton_class.class_variable_get(:@@rule) }
c.class_variable_set(:@@foo, 1)
assert_equal([:@@foo], c.singleton_class.class_variables)
assert_equal(1, c.singleton_class.class_variable_get(:@@foo))
c = Class.new
c.extend(Olympians)
sc = Class.new(c)
assert_empty(sc.singleton_class.class_variables)
assert_raise(NameError){ sc.singleton_class.class_variable_get(:@@rule) }
c.class_variable_set(:@@foo, 1)
assert_equal([:@@foo], sc.singleton_class.class_variables)
assert_equal(1, sc.singleton_class.class_variable_get(:@@foo))
c = Class.new
o = c.new
o.extend(Olympians)
assert_equal([:@@rule], o.singleton_class.class_variables)
assert_equal("Zeus", o.singleton_class.class_variable_get(:@@rule))
c.class_variable_set(:@@foo, 1)
assert_equal([:@@foo, :@@rule], o.singleton_class.class_variables.sort)
assert_equal(1, o.singleton_class.class_variable_get(:@@foo))
end
def test_variable
assert_instance_of(Integer, $$)
variable.c
mod_cvar_of(VALUE mod, void *data)
{
VALUE tmp = mod;
if (FL_TEST(mod, FL_SINGLETON)) {
if (rb_namespace_p(rb_ivar_get(mod, id__attached__))) {
data = mod_cvar_at(tmp, data);
tmp = cvar_front_klass(tmp);
}
}
for (;;) {
data = mod_cvar_at(tmp, data);
tmp = RCLASS_SUPER(tmp);
    (1-1/1)