From: eregontp@... Date: 2014-09-16T18:39:42+00:00 Subject: [ruby-core:65067] [ruby-trunk - Bug #10248] Possible missing test or bug for Module#include and Module#prepend Issue #10248 has been updated by Benoit Daloze. Module#ancestors is still respected for which modules to look up so it is somewhat consistent, but rather confusing indeed. Including a module in a class computes the module ancestors when it is included, and further (module) transitive inclusions are therefore not considered. But re-including the module works in this case as the last line shows. I do not know the reason of this but it very likely is spec. > class A; end > module B; end > class C < A; include B; end > module X; end > module B; include X; end > B.ancestors => [B, X] > C.ancestors => [C, B, A, Object, Kernel, BasicObject] > class D < A; include B; end > D.ancestors => [D, B, X, A, Object, Kernel, BasicObject] > class C < A; include B; end > C.ancestors => [C, B, X, A, Object, Kernel, BasicObject] ---------------------------------------- Bug #10248: Possible missing test or bug for Module#include and Module#prepend https://bugs.ruby-lang.org/issues/10248#change-48934 * Author: Timur Duehr * Status: Open * Priority: Normal * Assignee: * Category: * Target version: next minor * ruby -v: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin12.0] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN ---------------------------------------- I've been implementing Module#prepend for JRuby. I ran into this test https://github.com/jruby/jruby/blob/master/test/jruby/test_method_cache.rb#L19 This was unexpected behavior for me. I've looked through both the MRI and rubyspec test cases and don't see a similar test. If this behavior is intended, this test should be included in the suite. Currently, MRI passes this test for both include and prepend. When implementing include or prepend without referencing the MRI source code directly, the implementation won't necessarily pass this test. -- https://bugs.ruby-lang.org/