mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
5153260c30
commit
2a6727b566
1 changed files with 21 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue