diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-29 17:39:36 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-11-29 17:39:36 +0000 |
commit | 68336beb509b16404bc3a7e0e85eaaad8e9b8d30 (patch) | |
tree | 9f27c490edacc685ea1bc8bdeb8bc4e51c4a8658 /test | |
parent | ee490943c14e214cf9bee3d488d1ec6ba9b886fa (diff) |
merge revision(s) 33158,33185,33186:
* numeric.c (flo_round): substitute machine dependent magic number.
* numeric.c (flo_round): Make Float#round round big values [bug
#5272]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@33898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_float.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index fb37d73831..c244447bd7 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -315,7 +315,9 @@ class TestFloat < Test::Unit::TestCase assert_raise(FloatDomainError) { inf.ceil } assert_raise(FloatDomainError) { inf.round } assert_raise(FloatDomainError) { inf.truncate } + end + def test_round_with_precision assert_equal(1.100, 1.111.round(1)) assert_equal(1.110, 1.111.round(2)) assert_equal(11110.0, 11111.1.round(-1)) @@ -323,6 +325,17 @@ class TestFloat < Test::Unit::TestCase assert_equal(10**300, 1.1e300.round(-300)) assert_equal(-10**300, -1.1e300.round(-300)) + assert_equal(1.0e-300, 1.1e-300.round(300)) + assert_equal(-1.0e-300, -1.1e-300.round(300)) + + bug5227 = '[ruby-core:39093]' + assert_equal(42.0, 42.0.round(308), bug5227) + assert_equal(1.0e307, 1.0e307.round(2), bug5227) + + assert_raise(TypeError) {1.0.round("4")} + assert_raise(TypeError) {1.0.round(nil)} + def (prec = Object.new).to_int; 2; end + assert_equal(1.0, 0.998.round(prec)) end VS = [ |