diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-29 05:59:46 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-29 05:59:46 +0000 |
commit | d894e1d9301e4a87a42fa57be6492a9e01e5948f (patch) | |
tree | 7bb4d271bf129a75cd9c51a0a18fa6ccc0f6c5e2 | |
parent | 0a5d4d29e2404778d38410ba309443fa6e34ab03 (diff) | |
download | ruby-d894e1d9301e4a87a42fa57be6492a9e01e5948f.tar.gz |
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
-rw-r--r-- | class.c | 1 | ||||
-rw-r--r-- | test/ruby/test_module.rb | 8 |
2 files changed, 8 insertions, 1 deletions
@@ -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(); diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index f90543196b..453d850bb4 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -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)) |