diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-04-30 00:51:31 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-04-30 00:51:31 +0900 |
| commit | a092e4102066bb1a039fdccbd301d44f69114648 (patch) | |
| tree | d40243e80d9799d5ccb4b2cc14d8a987841420ab | |
| parent | 96637a7723bf337580f649e9b2fc77a40706d216 (diff) | |
| download | mruby-a092e4102066bb1a039fdccbd301d44f69114648.tar.gz mruby-a092e4102066bb1a039fdccbd301d44f69114648.zip | |
the receiver should be included in ancestors even when it's a singleton class
| -rw-r--r-- | src/class.c | 2 | ||||
| -rw-r--r-- | test/t/module.rb | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/class.c b/src/class.c index 0a29c3f63..47ea42228 100644 --- a/src/class.c +++ b/src/class.c @@ -796,6 +796,8 @@ mrb_mod_ancestors(mrb_state *mrb, mrb_value self) struct RClass *c = mrb_class_ptr(self); result = mrb_ary_new(mrb); + mrb_ary_push(mrb, result, mrb_obj_value(c)); + c = c->super; while (c) { if (c->tt == MRB_TT_ICLASS) { mrb_ary_push(mrb, result, mrb_obj_value(c->c)); diff --git a/test/t/module.rb b/test/t/module.rb index 41ee8d8df..8bcb75574 100644 --- a/test/t/module.rb +++ b/test/t/module.rb @@ -18,8 +18,7 @@ assert('Module#ancestors', '15.2.2.4.9') do end sc = Test4ModuleAncestors.singleton_class r = String.ancestors - r.class == Array and r.include?(String) and r.include?(Object) and - ! sc.ancestors.include?(sc) + r.class == Array and r.include?(String) and r.include?(Object) end assert('Module#append_features', '15.2.2.4.10') do |
