Module.include? behaves oddly #292

Closed
postmodern opened this Issue May 15, 2010 · 2 comments

Projects

None yet

2 participants

@postmodern
Contributor

I just noticed a difference in how Module.include? behaves, comapred to MRI. Module.include? claims that any module includes itself. I can see this behave being expected for Module.is_a? or Module.kind_of?. However, include? should only return true if the given Module was included into the ancestors stack, using the Class.include method.

Example script:

module Mixin
end

class Base
  include Mixin
end

class SuperClass < Base
end

puts "SuperClass includes Mixin" if SuperClass.include?(Mixin)
puts "Base includes Mixin" if Base.include?(Mixin)
puts "Mixin includes Mixin" if Mixin.include?(Mixin)

On Ruby 1.9.1:

$ ruby test_module_included.rb
SuperClass includes Mixin
Base includes Mixin

On JRuby 1.5.0:

$ rvm use jruby
$ ruby test_module_included.rb
SuperClass includes Mixin
Base includes Mixin

On Rubinius 1.0:

$ rbx test_module_included.rb 
SuperClass includes Mixin
Base includes Mixin
Mixin includes Mixin
@kronos
Member
kronos commented May 15, 2010

Spec & patch http://gist.github.com/402214 will be committed after reviewing core team

@kronos
Member
kronos commented May 16, 2010

Fix edge case for Module#include?. Closed by d3efd7b.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment