Skip to content

Commit

Permalink
Fix indentation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Sep 5, 2010
1 parent 88dfe16 commit d717ff9
Showing 1 changed file with 47 additions and 47 deletions.
94 changes: 47 additions & 47 deletions actionpack/test/template/number_helper_test.rb
Expand Up @@ -184,54 +184,54 @@ def test_number_to_human_size_with_custom_delimiter_and_separator
end

def test_number_to_human
assert_equal '0', number_to_human(0)
assert_equal '123', number_to_human(123)
assert_equal '1.23 Thousand', number_to_human(1234)
assert_equal '12.3 Thousand', number_to_human(12345)
assert_equal '1.23 Million', number_to_human(1234567)
assert_equal '1.23 Billion', number_to_human(1234567890)
assert_equal '1.23 Trillion', number_to_human(1234567890123)
assert_equal '1.23 Quadrillion', number_to_human(1234567890123456)
assert_equal '1230 Quadrillion', number_to_human(1234567890123456789)
assert_equal '490 Thousand', number_to_human(489939, :precision => 2)
assert_equal '489.9 Thousand', number_to_human(489939, :precision => 4)
assert_equal '489 Thousand', number_to_human(489000, :precision => 4)
assert_equal '489.0 Thousand', number_to_human(489000, :precision => 4, :strip_insignificant_zeros => false)
assert_equal '1.2346 Million', number_to_human(1234567, :precision => 4, :significant => false)
assert_equal '1,2 Million', number_to_human(1234567, :precision => 1, :significant => false, :separator => ',')
assert_equal '1 Million', number_to_human(1234567, :precision => 0, :significant => true, :separator => ',') #significant forced to false
assert_equal '0', number_to_human(0)
assert_equal '123', number_to_human(123)
assert_equal '1.23 Thousand', number_to_human(1234)
assert_equal '12.3 Thousand', number_to_human(12345)
assert_equal '1.23 Million', number_to_human(1234567)
assert_equal '1.23 Billion', number_to_human(1234567890)
assert_equal '1.23 Trillion', number_to_human(1234567890123)
assert_equal '1.23 Quadrillion', number_to_human(1234567890123456)
assert_equal '1230 Quadrillion', number_to_human(1234567890123456789)
assert_equal '490 Thousand', number_to_human(489939, :precision => 2)
assert_equal '489.9 Thousand', number_to_human(489939, :precision => 4)
assert_equal '489 Thousand', number_to_human(489000, :precision => 4)
assert_equal '489.0 Thousand', number_to_human(489000, :precision => 4, :strip_insignificant_zeros => false)
assert_equal '1.2346 Million', number_to_human(1234567, :precision => 4, :significant => false)
assert_equal '1,2 Million', number_to_human(1234567, :precision => 1, :significant => false, :separator => ',')
assert_equal '1 Million', number_to_human(1234567, :precision => 0, :significant => true, :separator => ',') #significant forced to false
end

def test_number_to_human_with_custom_units
#Only integers
volume = {:unit => "ml", :thousand => "lt", :million => "m3"}
assert_equal '123 lt', number_to_human(123456, :units => volume)
assert_equal '12 ml', number_to_human(12, :units => volume)
assert_equal '1.23 m3', number_to_human(1234567, :units => volume)

#Including fractionals
distance = {:mili => "mm", :centi => "cm", :deci => "dm", :unit => "m", :ten => "dam", :hundred => "hm", :thousand => "km"}
assert_equal '1.23 mm', number_to_human(0.00123, :units => distance)
assert_equal '1.23 cm', number_to_human(0.0123, :units => distance)
assert_equal '1.23 dm', number_to_human(0.123, :units => distance)
assert_equal '1.23 m', number_to_human(1.23, :units => distance)
assert_equal '1.23 dam', number_to_human(12.3, :units => distance)
assert_equal '1.23 hm', number_to_human(123, :units => distance)
assert_equal '1.23 km', number_to_human(1230, :units => distance)
assert_equal '1.23 km', number_to_human(1230, :units => distance)
assert_equal '1.23 km', number_to_human(1230, :units => distance)
assert_equal '12.3 km', number_to_human(12300, :units => distance)

#The quantifiers don't need to be a continuous sequence
gangster = {:hundred => "hundred bucks", :million => "thousand quids"}
assert_equal '1 hundred bucks', number_to_human(100, :units => gangster)
assert_equal '25 hundred bucks', number_to_human(2500, :units => gangster)
assert_equal '25 thousand quids', number_to_human(25000000, :units => gangster)
assert_equal '12300 thousand quids', number_to_human(12345000000, :units => gangster)

#Spaces are stripped from the resulting string
assert_equal '4', number_to_human(4, :units => {:unit => "", :ten => 'tens '})
assert_equal '4.5 tens', number_to_human(45, :units => {:unit => "", :ten => ' tens '})
#Only integers
volume = {:unit => "ml", :thousand => "lt", :million => "m3"}
assert_equal '123 lt', number_to_human(123456, :units => volume)
assert_equal '12 ml', number_to_human(12, :units => volume)
assert_equal '1.23 m3', number_to_human(1234567, :units => volume)

#Including fractionals
distance = {:mili => "mm", :centi => "cm", :deci => "dm", :unit => "m", :ten => "dam", :hundred => "hm", :thousand => "km"}
assert_equal '1.23 mm', number_to_human(0.00123, :units => distance)
assert_equal '1.23 cm', number_to_human(0.0123, :units => distance)
assert_equal '1.23 dm', number_to_human(0.123, :units => distance)
assert_equal '1.23 m', number_to_human(1.23, :units => distance)
assert_equal '1.23 dam', number_to_human(12.3, :units => distance)
assert_equal '1.23 hm', number_to_human(123, :units => distance)
assert_equal '1.23 km', number_to_human(1230, :units => distance)
assert_equal '1.23 km', number_to_human(1230, :units => distance)
assert_equal '1.23 km', number_to_human(1230, :units => distance)
assert_equal '12.3 km', number_to_human(12300, :units => distance)

#The quantifiers don't need to be a continuous sequence
gangster = {:hundred => "hundred bucks", :million => "thousand quids"}
assert_equal '1 hundred bucks', number_to_human(100, :units => gangster)
assert_equal '25 hundred bucks', number_to_human(2500, :units => gangster)
assert_equal '25 thousand quids', number_to_human(25000000, :units => gangster)
assert_equal '12300 thousand quids', number_to_human(12345000000, :units => gangster)

#Spaces are stripped from the resulting string
assert_equal '4', number_to_human(4, :units => {:unit => "", :ten => 'tens '})
assert_equal '4.5 tens', number_to_human(45, :units => {:unit => "", :ten => ' tens '})
end

def test_number_to_human_with_custom_format
Expand Down Expand Up @@ -342,7 +342,7 @@ def test_number_helpers_should_raise_error_if_invalid_when_specified
end

assert_raise InvalidNumberError do
number_with_delimiter("x", :raise => true)
number_with_delimiter("x", :raise => true)
end
begin
number_with_delimiter("x", :raise => true)
Expand All @@ -351,7 +351,7 @@ def test_number_helpers_should_raise_error_if_invalid_when_specified
end

assert_raise InvalidNumberError do
number_to_phone("x", :raise => true)
number_to_phone("x", :raise => true)
end
begin
number_to_phone("x", :raise => true)
Expand Down

0 comments on commit d717ff9

Please sign in to comment.