summaryrefslogtreecommitdiff
path: root/test/-ext-/num2int
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-01 12:22:56 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-01 12:22:56 +0000
commit809a7618f0ded5347d90597beb189da65bd98d90 (patch)
treefce6c5c675ec2bb1e646d7850fc1d34b40e8a5df /test/-ext-/num2int
parentd6daffbbf0350dbb6a164ec6264d5d2ea2f05c25 (diff)
* test/-ext-/num2int/test_num2int.rb: Test small bignums.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/-ext-/num2int')
-rw-r--r--test/-ext-/num2int/test_num2int.rb6
1 files changed, 6 insertions, 0 deletions
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