summaryrefslogtreecommitdiff
path: root/test/-ext-/num2int
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-27 13:12:27 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-03-27 13:12:27 +0000
commit83f1be1bc3a627620b6a7e95afef98a2cb1df5d5 (patch)
treeeceaa8dbf68f7d088fbfba1a90f1788e8c94059c /test/-ext-/num2int
parent7379116878c25b6411ce080268ed8e3a7e885f2f (diff)
* numeric.c (LONG_MIN_MINUS_ONE_IS_LESS_THAN): New macro.
(LLONG_MIN_MINUS_ONE_IS_LESS_THAN): Ditto. (rb_num2long): Use LONG_MIN_MINUS_ONE_IS_LESS_THAN. (rb_num2ulong): Ditto. (rb_num2ll): Use LLONG_MIN_MINUS_ONE_IS_LESS_THAN. (rb_num2ull): Ditto. * test/-ext-/num2int/test_num2int.rb (asert_num2i_success): Test the value converted into a Float if Float can represent the value exactly. (asert_num2i_error): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/-ext-/num2int')
-rw-r--r--test/-ext-/num2int/test_num2int.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/-ext-/num2int/test_num2int.rb b/test/-ext-/num2int/test_num2int.rb
index 90827fd..47e57ff 100644
--- a/test/-ext-/num2int/test_num2int.rb
+++ b/test/-ext-/num2int/test_num2int.rb
@@ -36,6 +36,11 @@ class TestNum2int < Test::Unit::TestCase
assert_output(result.to_s) do
Num2int.send(method, num)
end
+ if num.to_f.to_i == num
+ assert_output(result.to_s) do
+ Num2int.send(method, num.to_f)
+ end
+ end
end
def asert_num2i_error(type, num)
@@ -43,6 +48,11 @@ class TestNum2int < Test::Unit::TestCase
assert_raise(RangeError) do
Num2int.send(method, num)
end
+ if num.to_f.to_i == num
+ assert_raise(RangeError) do
+ Num2int.send(method, num)
+ end
+ end
end
def test_num2short