Fix Requirement equality
This commit is contained in:
parent
33dfc8e8b8
commit
9dfc5e39e8
@ -75,9 +75,10 @@ class Requirement
|
|||||||
self.class.env_proc
|
self.class.env_proc
|
||||||
end
|
end
|
||||||
|
|
||||||
def eql?(other)
|
def ==(other)
|
||||||
instance_of?(other.class) && name == other.name && tags == other.tags
|
instance_of?(other.class) && name == other.name && tags == other.tags
|
||||||
end
|
end
|
||||||
|
alias_method :eql?, :==
|
||||||
|
|
||||||
def hash
|
def hash
|
||||||
name.hash ^ tags.hash
|
name.hash ^ tags.hash
|
||||||
|
|||||||
@ -129,12 +129,14 @@ class RequirementTests < Homebrew::TestCase
|
|||||||
|
|
||||||
def test_eql
|
def test_eql
|
||||||
a, b = Requirement.new, Requirement.new
|
a, b = Requirement.new, Requirement.new
|
||||||
|
assert_equal a, b
|
||||||
assert_eql a, b
|
assert_eql a, b
|
||||||
assert_equal a.hash, b.hash
|
assert_equal a.hash, b.hash
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_not_eql
|
def test_not_eql
|
||||||
a, b = Requirement.new([:optional]), Requirement.new
|
a, b = Requirement.new([:optional]), Requirement.new
|
||||||
|
refute_equal a, b
|
||||||
refute_eql a, b
|
refute_eql a, b
|
||||||
refute_equal a.hash, b.hash
|
refute_equal a.hash, b.hash
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user