diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-27 00:42:11 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-10-27 00:42:11 +0000 |
commit | c94855855ed2abbfc9abd3d74ad2984d1b8ff14e (patch) | |
tree | 111fd30fd67a4d049baba70a3a36b470a7de8366 /test/ruby | |
parent | cc08515cf8ed0cdb5c38bbb4ef84a110e8868cd6 (diff) |
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/ruby')
-rw-r--r-- | test/ruby/test_integer.rb | 10 |
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 |