1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

instance_methods should not special-case singleton classes, fixes #2993

Signed-off-by: URABE, Shyouhei <shyouhei@ruby-lang.org>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shyouhei 2010-03-29 05:59:46 +00:00
parent 0a5d4d29e2
commit d894e1d930
2 changed files with 8 additions and 1 deletions

View file

@ -852,7 +852,6 @@ class_instance_method_list(int argc, VALUE *argv, VALUE mod, int (*func) (ID, lo
for (; mod; mod = RCLASS_SUPER(mod)) {
st_foreach(RCLASS_M_TBL(mod), method_entry, (st_data_t)list);
if (BUILTIN_TYPE(mod) == T_ICLASS) continue;
if (FL_TEST(mod, FL_SINGLETON)) continue;
if (!recur) break;
}
ary = rb_ary_new();

View file

@ -141,6 +141,11 @@ class TestModule < Test::Unit::TestCase
:bClass3
end
end
class CClass < BClass
def self.cClass
end
end
MyClass = AClass.clone
class MyClass
@ -281,6 +286,9 @@ class TestModule < Test::Unit::TestCase
assert_equal([:user, :mixin].sort, User.instance_methods(true).sort)
assert_equal([:mixin], Mixin.instance_methods)
assert_equal([:mixin], Mixin.instance_methods(true))
assert_equal([:cClass], (class << CClass; self; end).instance_methods(false))
assert_equal([], (class << BClass; self; end).instance_methods(false))
assert_equal([:cm2], (class << AClass; self; end).instance_methods(false))
# Ruby 1.8 feature change:
# #instance_methods includes protected methods.
#assert_equal([:aClass], AClass.instance_methods(false))