1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

test_float.rb: assertions for negative floats

* test/ruby/test_float.rb: add assertions for round,floor,ceil on
  negative floats.  [Feature #12245]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2016-04-18 03:40:03 +00:00
parent b25f06d314
commit adc7cb240a

View file

@ -428,6 +428,11 @@ class TestFloat < Test::Unit::TestCase
assert_equal(1.110, 1.111.round(2))
assert_equal(11110.0, 11111.1.round(-1))
assert_equal(11100.0, 11111.1.round(-2))
assert_equal(-1.100, -1.111.round(1))
assert_equal(-1.110, -1.111.round(2))
assert_equal(-11110.0, -11111.1.round(-1))
assert_equal(-11100.0, -11111.1.round(-2))
assert_equal(0, 11111.1.round(-5))
assert_equal(10**300, 1.1e300.round(-300))
assert_equal(-10**300, -1.1e300.round(-300))
@ -450,6 +455,11 @@ class TestFloat < Test::Unit::TestCase
assert_equal(11110, 11119.9.floor(-1))
assert_equal(11100, 11100.0.floor(-2))
assert_equal(11100, 11199.9.floor(-2))
assert_equal(-1.200, -1.111.floor(1))
assert_equal(-1.120, -1.111.floor(2))
assert_equal(-11120, -11119.9.floor(-1))
assert_equal(-11100, -11100.0.floor(-2))
assert_equal(-11200, -11199.9.floor(-2))
assert_equal(0, 11111.1.floor(-5))
assert_equal(10**300, 1.1e300.floor(-300))
@ -471,6 +481,10 @@ class TestFloat < Test::Unit::TestCase
assert_equal(1.120, 1.111.ceil(2))
assert_equal(11120, 11111.1.ceil(-1))
assert_equal(11200, 11111.1.ceil(-2))
assert_equal(-1.100, -1.111.ceil(1))
assert_equal(-1.110, -1.111.ceil(2))
assert_equal(-11110, -11111.1.ceil(-1))
assert_equal(-11100, -11111.1.ceil(-2))
assert_equal(100000, 11111.1.ceil(-5))
assert_equal(2*10**300, 1.1e300.ceil(-300))