diff options
| author | ksss <[email protected]> | 2014-03-21 22:24:33 +0900 |
|---|---|---|
| committer | ksss <[email protected]> | 2014-03-21 22:24:33 +0900 |
| commit | 8891cea41c8396012f786be00ee8d470f45241c1 (patch) | |
| tree | 0e78e71f6c0cb2fa6972ebee339e133a3e8f20e8 /test | |
| parent | 07bd65ae65ba1092191f5a702ce3c15aaca2ab5f (diff) | |
| download | mruby-8891cea41c8396012f786be00ee8d470f45241c1.tar.gz mruby-8891cea41c8396012f786be00ee8d470f45241c1.zip | |
Float#round fix bug for infinity and nan cases
Diffstat (limited to 'test')
| -rw-r--r-- | test/t/float.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/t/float.rb b/test/t/float.rb index c817e01da..ded434320 100644 --- a/test/t/float.rb +++ b/test/t/float.rb @@ -130,6 +130,18 @@ assert('Float#round', '15.2.9.3.12') do assert_equal( 3, g) assert_float( 3.4, h) assert_float(3.423, i) + + assert_equal(42.0, 42.0.round(307)) + assert_equal(1.0e307, 1.0e307.round(2)) + + inf = 1.0/0.0 + assert_raise(FloatDomainError){ inf.round } + assert_raise(FloatDomainError){ inf.round(-1) } + assert_equal(inf, inf.round(1)) + nan = 0.0/0.0 + assert_raise(FloatDomainError){ nan.round } + assert_raise(FloatDomainError){ nan.round(-1) } + assert_true(nan.round(1).nan?) end assert('Float#to_f', '15.2.9.3.13') do |
