1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
akr 2013-04-01 12:22:56 +00:00
parent d6daffbbf0
commit 809a7618f0
2 changed files with 10 additions and 0 deletions

View file

@ -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

View file

@ -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