[前][次][番号順一覧][スレッド一覧]

ruby-changes:42549

From: nobu <ko1@a...>
Date: Mon, 18 Apr 2016 11:43:28 +0900 (JST)
Subject: [ruby-changes:42549] nobu:r54623 (trunk): test_float.rb: assertions for negative floats

nobu	2016-04-18 12:40:03 +0900 (Mon, 18 Apr 2016)

  New Revision: 54623

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54623

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

  Modified files:
    trunk/test/ruby/test_float.rb
Index: test/ruby/test_float.rb
===================================================================
--- test/ruby/test_float.rb	(revision 54622)
+++ test/ruby/test_float.rb	(revision 54623)
@@ -428,6 +428,11 @@ class TestFloat < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_float.rb#L428
     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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_float.rb#L455
     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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_float.rb#L481
     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))

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]