diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-02 13:56:22 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-02 13:56:22 -0300 |
commit | f71265f7f8b3e284ec713b995c5d5b67557a3ef6 (patch) | |
tree | 15ad774a500e749120505e8932b01a05610abec0 /activesupport/test | |
parent | 38454bb2666ca7d258a4ca2b53e16bcc3a2ee019 (diff) | |
parent | 60062cf39a6079cf6a47a754f4b5fc6c474b9b15 (diff) | |
download | rails-f71265f7f8b3e284ec713b995c5d5b67557a3ef6.tar.gz rails-f71265f7f8b3e284ec713b995c5d5b67557a3ef6.tar.bz2 rails-f71265f7f8b3e284ec713b995c5d5b67557a3ef6.zip |
Merge pull request #15379 from xuanxu/rational_precision
Fix AS::NumberHelper results with rationals
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/number_helper_test.rb | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/activesupport/test/number_helper_test.rb b/activesupport/test/number_helper_test.rb index a7a0ae02e7..bb51cc68f2 100644 --- a/activesupport/test/number_helper_test.rb +++ b/activesupport/test/number_helper_test.rb @@ -134,6 +134,7 @@ module ActiveSupport assert_equal("111.23460000000000000000", number_helper.number_to_rounded('111.2346', :precision => 20)) assert_equal("111.23460000000000000000", number_helper.number_to_rounded(BigDecimal(111.2346, Float::DIG), :precision => 20)) assert_equal("111.2346" + "0"*96, number_helper.number_to_rounded('111.2346', :precision => 100)) + assert_equal("111.2346", number_helper.number_to_rounded(Rational(1112346, 10000), :precision => 4)) end end @@ -174,6 +175,7 @@ module ActiveSupport assert_equal "9775.0000000000000000", number_helper.number_to_rounded(BigDecimal(9775), :precision => 20, :significant => true ) assert_equal "9775.0000000000000000", number_helper.number_to_rounded("9775", :precision => 20, :significant => true ) assert_equal "9775." + "0"*96, number_helper.number_to_rounded("9775", :precision => 100, :significant => true ) + assert_equal("97.7", number_helper.number_to_rounded(Rational(9772, 100), :precision => 3, :significant => true)) end end |