ruby-changes:37738
From: gogotanaka <ko1@a...>
Date: Tue, 3 Mar 2015 14:59:50 +0900 (JST)
Subject: [ruby-changes:37738] gogotanaka:r49819 (trunk): * test/ruby/test_math.rb: add tests for the above change.
gogotanaka 2015-03-03 14:59:40 +0900 (Tue, 03 Mar 2015) New Revision: 49819 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49819 Log: * test/ruby/test_math.rb: add tests for the above change. Modified files: trunk/ChangeLog trunk/test/ruby/test_math.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 49818) +++ ChangeLog (revision 49819) @@ -3,6 +3,8 @@ Tue Mar 3 14:47:30 2015 Kazuki Tanaka https://github.com/ruby/ruby/blob/trunk/ChangeLog#L3 * math.c (num2dbl_with_to_f): direct casting from Rational to double. [Feature #10909] + * test/ruby/test_math.rb: add tests for the above change. + Tue Mar 3 07:52:20 2015 Rei Odaira <Rei.Odaira@g...> * test/ruby/test_symbol.rb: avoid a false positive in AIX. Index: test/ruby/test_math.rb =================================================================== --- test/ruby/test_math.rb (revision 49818) +++ test/ruby/test_math.rb (revision 49819) @@ -42,6 +42,12 @@ class TestMath < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_math.rb#L42 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_math.rb#L325 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/