summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-10 11:01:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-10 11:01:55 +0000
commitacc17bfc0f408846f07dff0c1f6f3d0f64390b81 (patch)
treefcaa76ede0cb2d9300e505521f0ed0f1a077481a /test
parent04e348e61ad5cfde94311b38c9b4f8581e205c0d (diff)
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
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_math.rb17
1 files changed, 12 insertions, 5 deletions
diff --git a/test/ruby/test_math.rb b/test/ruby/test_math.rb
index 6899137625f..be86579c550 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