From adc7cb240abea320c991430e98b633ad4e327e08 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 18 Apr 2016 03:40:03 +0000 Subject: [PATCH] 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 --- test/ruby/test_float.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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))