Created
May 15, 2010 14:22
-
-
Save kronos/402214 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/kernel/common/module.rb b/kernel/common/module.rb | |
index cd463b8..fe15498 100644 | |
--- a/kernel/common/module.rb | |
+++ b/kernel/common/module.rb | |
@@ -396,6 +396,8 @@ class Module | |
raise TypeError, "wrong argument type #{mod.class} (expected Module)" | |
end | |
+ return false if self.equal?(mod) | |
+ | |
_each_ancestor { |m| return true if mod.equal?(m) } | |
false | |
diff --git a/spec/ruby/core/module/include_spec.rb b/spec/ruby/core/module/include_spec.rb | |
index 799226e..333d2b4 100644 | |
--- a/spec/ruby/core/module/include_spec.rb | |
+++ b/spec/ruby/core/module/include_spec.rb | |
@@ -263,6 +263,10 @@ describe "Module#include?" do | |
ModuleSpecs::Basic.include?(ModuleSpecs::Super).should == false | |
end | |
+ it "returns false if given module is equal to self" do | |
+ ModuleSpecs.include?(ModuleSpecs).should == false | |
+ end | |
+ | |
it "raises a TypeError when no module was given" do | |
lambda { ModuleSpecs::Child.include?("Test") }.should raise_error(TypeError) | |
lambda { ModuleSpecs::Child.include?(ModuleSpecs::Parent) }.should raise_error(TypeError) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment