From 83f1be1bc3a627620b6a7e95afef98a2cb1df5d5 Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 27 Mar 2013 13:12:27 +0000 Subject: * 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 --- test/-ext-/num2int/test_num2int.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/-ext-') diff --git a/test/-ext-/num2int/test_num2int.rb b/test/-ext-/num2int/test_num2int.rb index 90827fdc1f..47e57fffc6 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 -- cgit v1.2.3