diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-18 03:40:03 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-04-18 03:40:03 +0000 |
commit | adc7cb240abea320c991430e98b633ad4e327e08 (patch) | |
tree | 60c5695c978499244a5f5a8f371874b86ac26b0f /test | |
parent | b25f06d314b1a72af236d5b0f603c3dd784e4d93 (diff) | |
download | ruby-adc7cb240abea320c991430e98b633ad4e327e08.tar.gz |
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
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_float.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index 6388b0943a..424436b088 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -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)) |