aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authoryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-22 10:29:40 +0000
committeryui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-12-22 10:29:40 +0000
commit15fffae4033b995b9adf78212a59f643fdfeec22 (patch)
tree7fe1749b9e108dc3764b6a0ddd2f1d6cd3711b8e /test
parentb746f128f466c5f17e6a5250de44242c39143b21 (diff)
downloadruby-15fffae4033b995b9adf78212a59f643fdfeec22.tar.gz
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
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_float.rb21
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)