diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2015-12-29 14:27:04 +0100 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2015-12-29 14:27:04 +0100 |
commit | 929c61573e289e432a4e571ae157248745ae2eae (patch) | |
tree | 275f88fdbc1a0c6c8baa20c567d6acb6b2766f9f /activesupport/test/core_ext/numeric_ext_test.rb | |
parent | 468df261f8a123dec1d36b22136476ae3660e1fa (diff) | |
parent | 007bb117c19d4a7c8119474c9897487e81cd4cd3 (diff) | |
download | rails-929c61573e289e432a4e571ae157248745ae2eae.tar.gz rails-929c61573e289e432a4e571ae157248745ae2eae.tar.bz2 rails-929c61573e289e432a4e571ae157248745ae2eae.zip |
Merge pull request #22622 from akshay-vishnoi/range_format_fix
Fix - `to_s(:db)` in numeric range
Diffstat (limited to 'activesupport/test/core_ext/numeric_ext_test.rb')
-rw-r--r-- | activesupport/test/core_ext/numeric_ext_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/numeric_ext_test.rb b/activesupport/test/core_ext/numeric_ext_test.rb index 42109a8f17..5654aeb4f8 100644 --- a/activesupport/test/core_ext/numeric_ext_test.rb +++ b/activesupport/test/core_ext/numeric_ext_test.rb @@ -406,6 +406,26 @@ class NumericExtFormattingTest < ActiveSupport::TestCase end end + def test_to_s_with_invalid_formatter + assert_equal '123', 123.to_s(:invalid) + assert_equal '2.5', 2.5.to_s(:invalid) + assert_equal '100000000000000000000', (100**10).to_s(:invalid) + assert_equal '1000010.0', BigDecimal("1000010").to_s(:invalid) + end + + def test_default_to_s + assert_equal '123', 123.to_s + assert_equal '1111011', 123.to_s(2) + + assert_equal '2.5', 2.5.to_s + + assert_equal '100000000000000000000', (100**10).to_s + assert_equal '1010110101111000111010111100010110101100011000100000000000000000000', (100**10).to_s(2) + + assert_equal '1000010.0', BigDecimal("1000010").to_s + assert_equal '10000 10.0', BigDecimal("1000010").to_s('5F') + end + def test_in_milliseconds assert_equal 10_000, 10.seconds.in_milliseconds end |