summaryrefslogtreecommitdiff
path: root/test/ruby/test_math.rb
diff options
context:
space:
mode:
authorgogotanaka <gogotanaka@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-03 05:59:40 +0000
committergogotanaka <gogotanaka@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-03 05:59:40 +0000
commitb5f8aec516533c32bfb296f8315ba2c64d4cf43e (patch)
treedbf55f88d474cd575bf8c80872284ed8b15812f0 /test/ruby/test_math.rb
parent972713cee1267c022483a8c6d6ccf713b6c3889d (diff)
* test/ruby/test_math.rb: add tests for the above change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_math.rb')
-rw-r--r--test/ruby/test_math.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_math.rb b/test/ruby/test_math.rb
index 5073166363..b6f41ed357 100644
--- a/test/ruby/test_math.rb
+++ b/test/ruby/test_math.rb
@@ -42,6 +42,12 @@ class TestMath < Test::Unit::TestCase
check(0.0, Math.cos(2 * Math::PI / 4))
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
@@ -319,4 +325,19 @@ class TestMath < Test::Unit::TestCase
Bignum.class_eval { alias to_f _to_f }
end
+
+ def test_override_rational_to_f
+ Rational.class_eval do
+ alias _to_f to_f
+ def to_f
+ (self + 1)._to_f
+ end
+ end
+
+ check(Math.cos((0r + 1)._to_f), Math.cos(0r))
+ check(Math.exp((0r + 1)._to_f), Math.exp(0r))
+ check(Math.log((0r + 1)._to_f), Math.log(0r))
+
+ Rational.class_eval { alias to_f _to_f }
+ end
end