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

ruby-changes:45078

From: yui-knk <ko1@a...>
Date: Thu, 22 Dec 2016 19:29:44 +0900 (JST)
Subject: [ruby-changes:45078] yui-knk:r57151 (trunk): test_float.rb: add test cases for Float#round

yui-knk	2016-12-22 19:29:40 +0900 (Thu, 22 Dec 2016)

  New Revision: 57151

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

  Log:
    test_float.rb: add test cases for Float#round
    
    * test_float.rb: add test cases for Float#round with
      half nil. Follow up r57130.

  Modified files:
    trunk/test/ruby/test_float.rb
Index: test/ruby/test_float.rb
===================================================================
--- test/ruby/test_float.rb	(revision 57150)
+++ test/ruby/test_float.rb	(revision 57151)
@@ -722,6 +722,27 @@ class TestFloat < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_float.rb#L722
     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)

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

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