diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb index 05318fc9ad..407623810e 100644 --- a/Library/Homebrew/dependency.rb +++ b/Library/Homebrew/dependency.rb @@ -21,7 +21,7 @@ class Dependency end def eql?(other) - instance_of?(other.class) && hash == other.hash + instance_of?(other.class) && name == other.name end def hash diff --git a/Library/Homebrew/options.rb b/Library/Homebrew/options.rb index c7d1acca22..b59cd29300 100644 --- a/Library/Homebrew/options.rb +++ b/Library/Homebrew/options.rb @@ -20,7 +20,7 @@ class Option end def eql?(other) - other.is_a?(self.class) && hash == other.hash + instance_of?(other.class) && name == other.name end def hash diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb index 317675b739..f710fd0215 100644 --- a/Library/Homebrew/requirement.rb +++ b/Library/Homebrew/requirement.rb @@ -54,7 +54,7 @@ class Requirement end def eql?(other) - instance_of?(other.class) && hash == other.hash + instance_of?(other.class) && name == other.name && tags == other.tags end def hash diff --git a/Library/Homebrew/test/test_requirement.rb b/Library/Homebrew/test/test_requirement.rb index 042aa922df..a2e50126e1 100644 --- a/Library/Homebrew/test/test_requirement.rb +++ b/Library/Homebrew/test/test_requirement.rb @@ -121,4 +121,18 @@ class RequirementTests < Test::Unit::TestCase req.to_dependency.modify_build_environment end end + + def test_eql + a, b = Requirement.new, Requirement.new + assert a.eql?(b) + assert b.eql?(a) + assert_equal a.hash, b.hash + end + + def test_not_eql + a, b = Requirement.new([:optional]), Requirement.new + assert_not_equal a.hash, b.hash + assert !a.eql?(b) + assert !b.eql?(a) + end end