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

ruby-changes:27986

From: akr <ko1@a...>
Date: Mon, 1 Apr 2013 21:23:06 +0900 (JST)
Subject: [ruby-changes:27986] akr:r40038 (trunk): * test/-ext-/num2int/test_num2int.rb: Test small bignums.

akr	2013-04-01 21:22:56 +0900 (Mon, 01 Apr 2013)

  New Revision: 40038

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40038

  Log:
    * test/-ext-/num2int/test_num2int.rb: Test small bignums.

  Modified files:
    trunk/ChangeLog
    trunk/test/-ext-/num2int/test_num2int.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40037)
+++ ChangeLog	(revision 40038)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Apr  1 21:22:31 2013  Tanaka Akira  <akr@f...>
+
+	* test/-ext-/num2int/test_num2int.rb: Test small bignums.
+
 Mon Apr  1 21:10:56 2013  Tanaka Akira  <akr@f...>
 
 	* numeric.c (rb_num2ulong_internal): Don't cast a negative double value
Index: test/-ext-/num2int/test_num2int.rb
===================================================================
--- test/-ext-/num2int/test_num2int.rb	(revision 40037)
+++ test/-ext-/num2int/test_num2int.rb	(revision 40038)
@@ -31,6 +31,10 @@ class TestNum2int < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/num2int/test_num2int.rb#L31
   FIXNUM_MAX = LONG_MAX/2
   FIXNUM_MIN = LONG_MIN/2
 
+  def fix2big(n)
+    10000000000000000000000000000.coerce(n)[0]
+  end
+
   def assert_num2i_success_internal(exp, func, arg)
     mesg = "#{func}(#{arg.inspect})"
     method = "rb_#{func}".downcase
@@ -44,6 +48,7 @@ class TestNum2int < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/num2int/test_num2int.rb#L48
   def assert_num2i_success(type, num, result=num)
     func = "NUM2#{type}".upcase
     assert_num2i_success_internal(result.to_s, func, num)
+    assert_num2i_success_internal(result.to_s, func, fix2big(num))
     if num.to_f.to_i == num
       assert_num2i_success_internal(result.to_s, func, num.to_f)
     end
@@ -68,6 +73,7 @@ class TestNum2int < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/num2int/test_num2int.rb#L73
   def assert_num2i_error(type, num)
     func = "NUM2#{type}".upcase
     assert_num2i_error_internal(func, num)
+    assert_num2i_error_internal(func, fix2big(num))
     if num.to_f.to_i == num
       assert_num2i_error_internal(func, num.to_f)
     end

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

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