Avoid unnecessary float to string conversion
This commit is contained in:
parent
43b85e5865
commit
e9d245cf3a
@ -81,9 +81,9 @@ end
|
||||
|
||||
def bottle_tag
|
||||
case MacOS.version
|
||||
when 10.8, 10.7, 10.5
|
||||
when "10.8", "10.7", "10.5"
|
||||
MacOS.cat
|
||||
when 10.6
|
||||
when "10.6"
|
||||
Hardware::CPU.is_64_bit? ? :snow_leopard : :snow_leopard_32
|
||||
else
|
||||
Hardware::CPU.type == :ppc ? Hardware::CPU.family : MacOS.cat
|
||||
|
||||
@ -11,11 +11,11 @@ module MacOS extend self
|
||||
|
||||
def cat
|
||||
case MacOS.version
|
||||
when 10.8 then :mountain_lion
|
||||
when 10.7 then :lion
|
||||
when 10.6 then :snow_leopard
|
||||
when 10.5 then :leopard
|
||||
when 10.4 then :tiger
|
||||
when "10.8" then :mountain_lion
|
||||
when "10.7" then :lion
|
||||
when "10.6" then :snow_leopard
|
||||
when "10.5" then :leopard
|
||||
when "10.4" then :tiger
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -19,11 +19,11 @@ module MacOS::Xcode extend self
|
||||
|
||||
def latest_version
|
||||
case MacOS.version
|
||||
when 10.4 then "2.5"
|
||||
when 10.5 then "3.1.4"
|
||||
when 10.6 then "3.2.6"
|
||||
when 10.7, 10.8 then "4.6.3"
|
||||
when 10.9 then "5.0"
|
||||
when "10.4" then "2.5"
|
||||
when "10.5" then "3.1.4"
|
||||
when "10.6" then "3.2.6"
|
||||
when "10.7", "10.8" then "4.6.3"
|
||||
when "10.9" then "5.0"
|
||||
else
|
||||
# Default to newest known version of Xcode for unreleased OSX versions.
|
||||
if MacOS.version > 10.9
|
||||
|
||||
@ -3,42 +3,42 @@ require 'bottles'
|
||||
|
||||
class BottleTagTests < Test::Unit::TestCase
|
||||
def test_cat_tiger_ppc
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new(10.4))
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new("10.4"))
|
||||
Hardware::CPU.stubs(:type).returns(:ppc)
|
||||
Hardware::CPU.stubs(:family).returns(:foo)
|
||||
assert_equal :foo, bottle_tag
|
||||
end
|
||||
|
||||
def test_cat_tiger_intel
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new(10.4))
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new("10.4"))
|
||||
Hardware::CPU.stubs(:type).returns(:intel)
|
||||
assert_equal :tiger, bottle_tag
|
||||
end
|
||||
|
||||
def test_cat_leopard
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new(10.5))
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new("10.5"))
|
||||
assert_equal :leopard, bottle_tag
|
||||
end
|
||||
|
||||
def test_cat_snow_leopard_32
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new(10.6))
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new("10.6"))
|
||||
Hardware::CPU.stubs(:is_64_bit?).returns(false)
|
||||
assert_equal :snow_leopard_32, bottle_tag
|
||||
end
|
||||
|
||||
def test_cat_snow_leopard_64
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new(10.6))
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new("10.6"))
|
||||
Hardware::CPU.stubs(:is_64_bit?).returns(true)
|
||||
assert_equal :snow_leopard, bottle_tag
|
||||
end
|
||||
|
||||
def test_cat_lion
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new(10.7))
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new("10.7"))
|
||||
assert_equal :lion, bottle_tag
|
||||
end
|
||||
|
||||
def test_cat_mountain_lion
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new(10.8))
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new("10.8"))
|
||||
assert_equal :mountain_lion, bottle_tag
|
||||
end
|
||||
end
|
||||
|
||||
@ -102,22 +102,22 @@ class DependencyCollectorTests < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_x11_proxy_dep_mountain_lion
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new(10.8))
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new("10.8"))
|
||||
assert_equal Dependency.new("libpng"), @d.build(:libpng)
|
||||
end
|
||||
|
||||
def test_x11_proxy_dep_lion_or_older
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new(10.7))
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new("10.7"))
|
||||
assert_equal X11Dependency::Proxy.new(:libpng), @d.build(:libpng)
|
||||
end
|
||||
|
||||
def test_ld64_dep_pre_leopard
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new(10.4))
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new("10.4"))
|
||||
assert_equal LD64Dependency.new, @d.build(:ld64)
|
||||
end
|
||||
|
||||
def test_ld64_dep_leopard_or_newer
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new(10.5))
|
||||
MacOS.stubs(:version).returns(MacOS::Version.new("10.5"))
|
||||
assert_nil @d.build(:ld64)
|
||||
end
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ require 'os/mac/version'
|
||||
|
||||
class MacOSVersionTests < Test::Unit::TestCase
|
||||
def setup
|
||||
@v = MacOS::Version.new(10.7)
|
||||
@v = MacOS::Version.new("10.7")
|
||||
end
|
||||
|
||||
def test_compare_with_symbol
|
||||
@ -34,9 +34,9 @@ class MacOSVersionTests < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
def test_compare_with_version
|
||||
assert_operator @v, :>, Version.new(10.6)
|
||||
assert_operator @v, :==, Version.new(10.7)
|
||||
assert_operator @v, :===, Version.new(10.7)
|
||||
assert_operator @v, :<, Version.new(10.8)
|
||||
assert_operator @v, :>, Version.new("10.6")
|
||||
assert_operator @v, :==, Version.new("10.7")
|
||||
assert_operator @v, :===, Version.new("10.7")
|
||||
assert_operator @v, :<, Version.new("10.8")
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user