summaryrefslogtreecommitdiff
path: root/test/-ext-/num2int
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-31 04:51:29 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-31 04:51:29 +0000
commit59182ccf69b5c0bcbf3a939a3595956bc592f234 (patch)
treed202df6338b83ddd3e3fd4e0bba7e453b5653186 /test/-ext-/num2int
parent18affefbe5e7d0d940e7f924b375c4bde00ac380 (diff)
* 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
Diffstat (limited to 'test/-ext-/num2int')
-rw-r--r--test/-ext-/num2int/test_num2int.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/-ext-/num2int/test_num2int.rb b/test/-ext-/num2int/test_num2int.rb
index 2ec12c0..deeb33e 100644
--- a/test/-ext-/num2int/test_num2int.rb
+++ b/test/-ext-/num2int/test_num2int.rb
@@ -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)