diff options
author | Don Wilson <robert.don.wilson@gmail.com> | 2010-12-17 09:56:03 -0700 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-12-18 10:00:37 +0100 |
commit | f71809f25761440cbec9463bbc082987c90a471b (patch) | |
tree | aa1f2506a40fe34229f0ec074b73058be8b0e78d /actionpack/test | |
parent | 5008d33eee4767cd84b1087ceec827f1eaec90d0 (diff) | |
download | rails-f71809f25761440cbec9463bbc082987c90a471b.tar.gz rails-f71809f25761440cbec9463bbc082987c90a471b.tar.bz2 rails-f71809f25761440cbec9463bbc082987c90a471b.zip |
Fixed number_with_precision rounding error [#6182 state:resolved]
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/template/number_helper_test.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/actionpack/test/template/number_helper_test.rb b/actionpack/test/template/number_helper_test.rb index ab127521ad..156b7cb5ff 100644 --- a/actionpack/test/template/number_helper_test.rb +++ b/actionpack/test/template/number_helper_test.rb @@ -100,6 +100,8 @@ class NumberHelperTest < ActionView::TestCase assert_equal("0", number_with_precision(0, :precision => 0)) assert_equal("0.00100", number_with_precision(0.001, :precision => 5)) assert_equal("0.001", number_with_precision(0.00111, :precision => 3)) + assert_equal("10.00", number_with_precision(9.995, :precision => 2)) + assert_equal("11.00", number_with_precision(10.995, :precision => 2)) end def test_number_with_precision_with_custom_delimiter_and_separator @@ -125,6 +127,9 @@ class NumberHelperTest < ActionView::TestCase assert_equal "0.0001", number_with_precision(0.0001, :precision => 1, :significant => true ) assert_equal "0.000100", number_with_precision(0.0001, :precision => 3, :significant => true ) assert_equal "0.0001", number_with_precision(0.0001111, :precision => 1, :significant => true ) + assert_equal "10.0", number_with_precision(9.995, :precision => 3, :significant => true) + assert_equal "9.99", number_with_precision(9.994, :precision => 3, :significant => true) + assert_equal "11.0", number_with_precision(10.995, :precision => 3, :significant => true) end def test_number_with_precision_with_strip_insignificant_zeros |