From acc17bfc0f408846f07dff0c1f6f3d0f64390b81 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 10 Mar 2015 11:01:55 +0000 Subject: test_math.rb: to_f tests * test/ruby/test_math.rb (test_{fixnum,bignum,rational}_to_f): refine to_f tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_math.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'test/ruby/test_math.rb') diff --git a/test/ruby/test_math.rb b/test/ruby/test_math.rb index 6899137625..be86579c55 100644 --- a/test/ruby/test_math.rb +++ b/test/ruby/test_math.rb @@ -49,11 +49,6 @@ class TestMath < Test::Unit::TestCase check(-1.0, Math.cos(4 * Math::PI / 4)) check(0.0, Math.cos(6 * Math::PI / 4)) check(0.5403023058681398, Math.cos(1)) - check(-0.7112665029764864, Math.cos(1 << 62)) - check(0.9289154176164999, Math.cos((2 ** 62)/(3 ** 40).to_r)) - check(0.9820680774815206, Math.cos((2 ** 61)/(3 ** 40).to_r)) - check(0.4194382061248139, Math.cos((2 ** 62)/(3 ** 39).to_r)) - check(0.8424482791616391, Math.cos((2 ** 61)/(3 ** 39).to_r)) end def test_sin @@ -272,6 +267,10 @@ class TestMath < Test::Unit::TestCase assert_raise(Math::DomainError) { Math.lgamma(-Float::INFINITY) } end + def test_fixnum_to_f + check(12.0, Math.sqrt(144)) + end + def test_override_fixnum_to_f Fixnum.class_eval do alias _to_f to_f @@ -287,6 +286,10 @@ class TestMath < Test::Unit::TestCase Fixnum.class_eval { alias to_f _to_f } end + def test_bignum_to_f + check((1 << 65).to_f, Math.sqrt(1 << 130)) + end + def test_override_bignum_to_f Bignum.class_eval do alias _to_f to_f @@ -301,6 +304,10 @@ class TestMath < Test::Unit::TestCase Bignum.class_eval { alias to_f _to_f } end + def test_rational_to_f + check((2 ** 31).fdiv(3 ** 20), Math.sqrt((2 ** 62)/(3 ** 40).to_r)) + end + def test_override_rational_to_f Rational.class_eval do alias _to_f to_f -- cgit v1.2.3