aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-27 00:42:11 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-27 00:42:11 +0000
commita18f3f4dbdec695765637b21b9c2526f30e6946c (patch)
tree111fd30fd67a4d049baba70a3a36b470a7de8366 /test
parent70f820784179fa6d84220b335b3a286ced0eb8fd (diff)
downloadruby-a18f3f4dbdec695765637b21b9c2526f30e6946c.tar.gz
object.c: fixable float to fixnum
* object.c (rb_convert_to_integer): convert a fixable float to a fixnum directly without the convesion method, as well as bignum case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_integer.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_integer.rb b/test/ruby/test_integer.rb
index 32c3511576..00c3c12577 100644
--- a/test/ruby/test_integer.rb
+++ b/test/ruby/test_integer.rb
@@ -104,6 +104,16 @@ class TestInteger < Test::Unit::TestCase
obj = Struct.new(:s).new(%w[42 not-an-integer])
def obj.to_str; s.shift; end
assert_equal(42, Integer(obj, 10))
+
+ assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}")
+ begin;
+ class Float
+ undef to_int
+ def to_int; raise "conversion failed"; end
+ end
+ assert_equal (1 << 100), Integer((1 << 100).to_f)
+ assert_equal 1, Integer(1.0)
+ end;
end
def test_int_p