mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* numeric.c (rb_num2ulong_internal): New function similart to
rb_num2ulong but integer wrap around flag is also returned. (rb_num2ulong): Use rb_num2ulong_internal. (rb_num2uint): Use rb_num2ulong_internal and the wrap around flag is used instead of negative_int_p(val). (rb_num2ushort): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
18affefbe5
commit
59182ccf69
3 changed files with 52 additions and 11 deletions
|
|
@ -48,6 +48,17 @@ class TestNum2int < Test::Unit::TestCase
|
|||
if num.to_f.to_i == num
|
||||
assert_num2i_success_internal(result.to_s, func, num.to_f)
|
||||
end
|
||||
if num == result
|
||||
# The conversion functions such as NUM2INT uses to_int (conceptually).
|
||||
arg = num.to_f + 0.5
|
||||
if arg != num.to_f && arg.to_int == num
|
||||
assert_num2i_success_internal(result.to_s, func, arg)
|
||||
end
|
||||
arg = num.to_f - 0.5
|
||||
if arg != num.to_f && arg.to_int == num
|
||||
assert_num2i_success_internal(result.to_s, func, arg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def assert_num2i_error_internal(func, arg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue