Fix Formula#<=> on trunk Ruby
Arguably this method shouldn't exist and sort_by(&:name) used instead.
This commit is contained in:
parent
618b894c3e
commit
b78308d2d5
@ -301,9 +301,12 @@ class Formula
|
|||||||
def hash
|
def hash
|
||||||
name.hash
|
name.hash
|
||||||
end
|
end
|
||||||
def <=> b
|
|
||||||
name <=> b.name
|
def <=>(other)
|
||||||
|
return unless Formula === other
|
||||||
|
name <=> other.name
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
name
|
name
|
||||||
end
|
end
|
||||||
|
@ -139,6 +139,10 @@ class FormulaTests < Homebrew::TestCase
|
|||||||
refute_equal TestBall.new, Object.new
|
refute_equal TestBall.new, Object.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_sort_operator
|
||||||
|
assert_nil TestBall.new <=> Object.new
|
||||||
|
end
|
||||||
|
|
||||||
def test_class_naming
|
def test_class_naming
|
||||||
assert_equal 'ShellFm', Formulary.class_s('shell.fm')
|
assert_equal 'ShellFm', Formulary.class_s('shell.fm')
|
||||||
assert_equal 'Fooxx', Formulary.class_s('foo++')
|
assert_equal 'Fooxx', Formulary.class_s('foo++')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user