From e9d245cf3a6e1ce783931e8e339c11fb0f3757d5 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sat, 15 Jun 2013 09:33:30 -0500 Subject: [PATCH] Avoid unnecessary float to string conversion --- Library/Homebrew/bottles.rb | 4 ++-- Library/Homebrew/macos.rb | 10 +++++----- Library/Homebrew/os/mac/xcode.rb | 10 +++++----- Library/Homebrew/test/test_bottle_tag.rb | 14 +++++++------- Library/Homebrew/test/test_dependency_collector.rb | 8 ++++---- Library/Homebrew/test/test_version_subclasses.rb | 10 +++++----- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Library/Homebrew/bottles.rb b/Library/Homebrew/bottles.rb index 7d9545f380..e043df2b07 100644 --- a/Library/Homebrew/bottles.rb +++ b/Library/Homebrew/bottles.rb @@ -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 diff --git a/Library/Homebrew/macos.rb b/Library/Homebrew/macos.rb index 91c2050e8a..54cf434877 100644 --- a/Library/Homebrew/macos.rb +++ b/Library/Homebrew/macos.rb @@ -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 diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index eaae6fbf88..3fdd904630 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -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 diff --git a/Library/Homebrew/test/test_bottle_tag.rb b/Library/Homebrew/test/test_bottle_tag.rb index 2b039a29fd..3dc51943a8 100644 --- a/Library/Homebrew/test/test_bottle_tag.rb +++ b/Library/Homebrew/test/test_bottle_tag.rb @@ -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 diff --git a/Library/Homebrew/test/test_dependency_collector.rb b/Library/Homebrew/test/test_dependency_collector.rb index 0b4c19ebf7..dafc83da09 100644 --- a/Library/Homebrew/test/test_dependency_collector.rb +++ b/Library/Homebrew/test/test_dependency_collector.rb @@ -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 diff --git a/Library/Homebrew/test/test_version_subclasses.rb b/Library/Homebrew/test/test_version_subclasses.rb index 6b18246ba2..546fcadaa7 100644 --- a/Library/Homebrew/test/test_version_subclasses.rb +++ b/Library/Homebrew/test/test_version_subclasses.rb @@ -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