summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--test/-ext-/num2int/test_num2int.rb6
2 files changed, 10 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 48902b0..b7b7f9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Mon Apr 1 21:22:31 2013 Tanaka Akira <akr@fsij.org>
+
+ * test/-ext-/num2int/test_num2int.rb: Test small bignums.
+
Mon Apr 1 21:10:56 2013 Tanaka Akira <akr@fsij.org>
* numeric.c (rb_num2ulong_internal): Don't cast a negative double value
diff --git a/test/-ext-/num2int/test_num2int.rb b/test/-ext-/num2int/test_num2int.rb
index 2add0f6..f421ae0 100644
--- a/test/-ext-/num2int/test_num2int.rb
+++ b/test/-ext-/num2int/test_num2int.rb
@@ -31,6 +31,10 @@ class TestNum2int < Test::Unit::TestCase
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
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
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