mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix indentation errors
This commit is contained in:
parent
88dfe16d95
commit
d717ff9e52
1 changed files with 44 additions and 44 deletions
|
@ -184,54 +184,54 @@ class NumberHelperTest < ActionView::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_number_to_human
|
def test_number_to_human
|
||||||
assert_equal '0', number_to_human(0)
|
assert_equal '0', number_to_human(0)
|
||||||
assert_equal '123', number_to_human(123)
|
assert_equal '123', number_to_human(123)
|
||||||
assert_equal '1.23 Thousand', number_to_human(1234)
|
assert_equal '1.23 Thousand', number_to_human(1234)
|
||||||
assert_equal '12.3 Thousand', number_to_human(12345)
|
assert_equal '12.3 Thousand', number_to_human(12345)
|
||||||
assert_equal '1.23 Million', number_to_human(1234567)
|
assert_equal '1.23 Million', number_to_human(1234567)
|
||||||
assert_equal '1.23 Billion', number_to_human(1234567890)
|
assert_equal '1.23 Billion', number_to_human(1234567890)
|
||||||
assert_equal '1.23 Trillion', number_to_human(1234567890123)
|
assert_equal '1.23 Trillion', number_to_human(1234567890123)
|
||||||
assert_equal '1.23 Quadrillion', number_to_human(1234567890123456)
|
assert_equal '1.23 Quadrillion', number_to_human(1234567890123456)
|
||||||
assert_equal '1230 Quadrillion', number_to_human(1234567890123456789)
|
assert_equal '1230 Quadrillion', number_to_human(1234567890123456789)
|
||||||
assert_equal '490 Thousand', number_to_human(489939, :precision => 2)
|
assert_equal '490 Thousand', number_to_human(489939, :precision => 2)
|
||||||
assert_equal '489.9 Thousand', number_to_human(489939, :precision => 4)
|
assert_equal '489.9 Thousand', number_to_human(489939, :precision => 4)
|
||||||
assert_equal '489 Thousand', number_to_human(489000, :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 '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.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,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 '1 Million', number_to_human(1234567, :precision => 0, :significant => true, :separator => ',') #significant forced to false
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_number_to_human_with_custom_units
|
def test_number_to_human_with_custom_units
|
||||||
#Only integers
|
#Only integers
|
||||||
volume = {:unit => "ml", :thousand => "lt", :million => "m3"}
|
volume = {:unit => "ml", :thousand => "lt", :million => "m3"}
|
||||||
assert_equal '123 lt', number_to_human(123456, :units => volume)
|
assert_equal '123 lt', number_to_human(123456, :units => volume)
|
||||||
assert_equal '12 ml', number_to_human(12, :units => volume)
|
assert_equal '12 ml', number_to_human(12, :units => volume)
|
||||||
assert_equal '1.23 m3', number_to_human(1234567, :units => volume)
|
assert_equal '1.23 m3', number_to_human(1234567, :units => volume)
|
||||||
|
|
||||||
#Including fractionals
|
#Including fractionals
|
||||||
distance = {:mili => "mm", :centi => "cm", :deci => "dm", :unit => "m", :ten => "dam", :hundred => "hm", :thousand => "km"}
|
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 mm', number_to_human(0.00123, :units => distance)
|
||||||
assert_equal '1.23 cm', number_to_human(0.0123, :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 dm', number_to_human(0.123, :units => distance)
|
||||||
assert_equal '1.23 m', number_to_human(1.23, :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 dam', number_to_human(12.3, :units => distance)
|
||||||
assert_equal '1.23 hm', number_to_human(123, :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 '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)
|
assert_equal '12.3 km', number_to_human(12300, :units => distance)
|
||||||
|
|
||||||
#The quantifiers don't need to be a continuous sequence
|
#The quantifiers don't need to be a continuous sequence
|
||||||
gangster = {:hundred => "hundred bucks", :million => "thousand quids"}
|
gangster = {:hundred => "hundred bucks", :million => "thousand quids"}
|
||||||
assert_equal '1 hundred bucks', number_to_human(100, :units => gangster)
|
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 hundred bucks', number_to_human(2500, :units => gangster)
|
||||||
assert_equal '25 thousand quids', number_to_human(25000000, :units => gangster)
|
assert_equal '25 thousand quids', number_to_human(25000000, :units => gangster)
|
||||||
assert_equal '12300 thousand quids', number_to_human(12345000000, :units => gangster)
|
assert_equal '12300 thousand quids', number_to_human(12345000000, :units => gangster)
|
||||||
|
|
||||||
#Spaces are stripped from the resulting string
|
#Spaces are stripped from the resulting string
|
||||||
assert_equal '4', number_to_human(4, :units => {:unit => "", :ten => 'tens '})
|
assert_equal '4', number_to_human(4, :units => {:unit => "", :ten => 'tens '})
|
||||||
assert_equal '4.5 tens', number_to_human(45, :units => {:unit => "", :ten => ' tens '})
|
assert_equal '4.5 tens', number_to_human(45, :units => {:unit => "", :ten => ' tens '})
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_number_to_human_with_custom_format
|
def test_number_to_human_with_custom_format
|
||||||
|
@ -342,7 +342,7 @@ class NumberHelperTest < ActionView::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_raise InvalidNumberError do
|
assert_raise InvalidNumberError do
|
||||||
number_with_delimiter("x", :raise => true)
|
number_with_delimiter("x", :raise => true)
|
||||||
end
|
end
|
||||||
begin
|
begin
|
||||||
number_with_delimiter("x", :raise => true)
|
number_with_delimiter("x", :raise => true)
|
||||||
|
@ -351,7 +351,7 @@ class NumberHelperTest < ActionView::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
assert_raise InvalidNumberError do
|
assert_raise InvalidNumberError do
|
||||||
number_to_phone("x", :raise => true)
|
number_to_phone("x", :raise => true)
|
||||||
end
|
end
|
||||||
begin
|
begin
|
||||||
number_to_phone("x", :raise => true)
|
number_to_phone("x", :raise => true)
|
||||||
|
|
Loading…
Reference in a new issue