From 15fffae4033b995b9adf78212a59f643fdfeec22 Mon Sep 17 00:00:00 2001 From: yui-knk Date: Thu, 22 Dec 2016 10:29:40 +0000 Subject: 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 --- test/ruby/test_float.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test/ruby/test_float.rb') 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) -- cgit v1.2.3