diff options
author | yui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-22 10:29:40 +0000 |
---|---|---|
committer | yui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-22 10:29:40 +0000 |
commit | 2a6727b566370df1745ab062756adffa79221bce (patch) | |
tree | 7fe1749b9e108dc3764b6a0ddd2f1d6cd3711b8e | |
parent | 5153260c309d19aef3b34dad5e1da05c3dbf1e9e (diff) |
test_float.rb: add test cases for Float#round
* test_float.rb: add test cases for Float#round with
half nil. Follow up r57130.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | test/ruby/test_float.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index 5a566879b7..dfe636045d 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -722,6 +722,27 @@ class TestFloat < Test::Unit::TestCase assert_equal(-7.1364, -7.1364499.round(4, half: :down)) end + def test_round_half_nil + assert_equal(13.0, 12.5.round(half: nil)) + assert_equal(14.0, 13.5.round(half: nil)) + + assert_equal(2.2, 2.15.round(1, half: nil)) + assert_equal(2.3, 2.25.round(1, half: nil)) + assert_equal(2.4, 2.35.round(1, half: nil)) + + assert_equal(-2.2, -2.15.round(1, half: nil)) + assert_equal(-2.3, -2.25.round(1, half: nil)) + assert_equal(-2.4, -2.35.round(1, half: nil)) + + assert_equal(7.1365, 7.13645.round(4, half: nil)) + assert_equal(7.1365, 7.1364501.round(4, half: nil)) + assert_equal(7.1364, 7.1364499.round(4, half: nil)) + + assert_equal(-7.1365, -7.13645.round(4, half: nil)) + assert_equal(-7.1365, -7.1364501.round(4, half: nil)) + assert_equal(-7.1364, -7.1364499.round(4, half: nil)) + end + def test_round_half_invalid assert_raise_with_message(ArgumentError, /Object/) { 1.0.round(half: Object) |