mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/ruby/test_math.rb: actual-expected argument ordering for
test_math.rb fixed. a patch from Tadashi Saito <shiba AT mail2.accsnet.ne.jp> in [ruby-dev:33770]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3a9bf2f124
commit
c4b18d3cc5
2 changed files with 31 additions and 25 deletions
|
@ -1,3 +1,9 @@
|
|||
Thu Feb 14 16:07:40 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* test/ruby/test_math.rb: actual-expected argument ordering for
|
||||
test_math.rb fixed. a patch from Tadashi Saito
|
||||
<shiba AT mail2.accsnet.ne.jp> in [ruby-dev:33770].
|
||||
|
||||
Thu Feb 14 16:02:51 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* file.c (rb_file_s_utime): inhibits with secure level 2 or higher.
|
||||
|
|
|
@ -6,32 +6,32 @@ class TestMath < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_atan2
|
||||
check(Math.atan2(0, 1), 0)
|
||||
check(Math.atan2(1, 1), Math::PI / 4)
|
||||
check(Math.atan2(1, 0), Math::PI / 2)
|
||||
check(0, Math.atan2(0, 1))
|
||||
check(Math::PI / 4, Math.atan2(1, 1))
|
||||
check(Math::PI / 2, Math.atan2(1, 0))
|
||||
end
|
||||
|
||||
def test_cos
|
||||
check(Math.cos(0 * Math::PI / 4), 1.0)
|
||||
check(Math.cos(1 * Math::PI / 4), 1.0 / Math.sqrt(2))
|
||||
check(Math.cos(2 * Math::PI / 4), 0.0)
|
||||
check(Math.cos(4 * Math::PI / 4), -1.0)
|
||||
check(Math.cos(6 * Math::PI / 4), 0.0)
|
||||
check(1.0, Math.cos(0 * Math::PI / 4))
|
||||
check(1.0 / Math.sqrt(2), Math.cos(1 * Math::PI / 4))
|
||||
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))
|
||||
end
|
||||
|
||||
def test_sin
|
||||
check(Math.sin(0 * Math::PI / 4), 0.0)
|
||||
check(Math.sin(1 * Math::PI / 4), 1.0 / Math.sqrt(2))
|
||||
check(Math.sin(2 * Math::PI / 4), 1.0)
|
||||
check(Math.sin(4 * Math::PI / 4), 0.0)
|
||||
check(Math.sin(6 * Math::PI / 4), -1.0)
|
||||
check(0.0, Math.sin(0 * Math::PI / 4))
|
||||
check(1.0 / Math.sqrt(2), Math.sin(1 * Math::PI / 4))
|
||||
check(1.0, Math.sin(2 * Math::PI / 4))
|
||||
check(0.0, Math.sin(4 * Math::PI / 4))
|
||||
check(-1.0, Math.sin(6 * Math::PI / 4))
|
||||
end
|
||||
|
||||
def test_tan
|
||||
check(Math.tan(0 * Math::PI / 4), 0.0)
|
||||
check(Math.tan(1 * Math::PI / 4), 1.0)
|
||||
check(0.0, Math.tan(0 * Math::PI / 4))
|
||||
check(1.0, Math.tan(1 * Math::PI / 4))
|
||||
assert(Math.tan(2 * Math::PI / 4).abs > 1024)
|
||||
check(Math.tan(4 * Math::PI / 4), 0.0)
|
||||
check(0.0, Math.tan(4 * Math::PI / 4))
|
||||
assert(Math.tan(6 * Math::PI / 4).abs > 1024)
|
||||
end
|
||||
|
||||
|
@ -77,22 +77,22 @@ class TestMath < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_acosh
|
||||
check(Math.acosh(1), 0)
|
||||
check(Math.acosh((Math::E ** 1 + Math::E ** -1) / 2), 1)
|
||||
check(Math.acosh((Math::E ** 2 + Math::E ** -2) / 2), 2)
|
||||
check(0, Math.acosh(1))
|
||||
check(1, Math.acosh((Math::E ** 1 + Math::E ** -1) / 2))
|
||||
check(2, Math.acosh((Math::E ** 2 + Math::E ** -2) / 2))
|
||||
assert_raise(Errno::EDOM, Errno::ERANGE) { Math.acosh(0) }
|
||||
end
|
||||
|
||||
def test_asinh
|
||||
check(Math.asinh(0), 0)
|
||||
check(Math.asinh((Math::E ** 1 - Math::E ** -1) / 2), 1)
|
||||
check(Math.asinh((Math::E ** 2 - Math::E ** -2) / 2), 2)
|
||||
check(0, Math.asinh(0))
|
||||
check(1, Math.asinh((Math::E ** 1 - Math::E ** -1) / 2))
|
||||
check(2, Math.asinh((Math::E ** 2 - Math::E ** -2) / 2))
|
||||
end
|
||||
|
||||
def test_atanh
|
||||
check(Math.atanh(Math.sinh(0) / Math.cosh(0)), 0)
|
||||
check(Math.atanh(Math.sinh(1) / Math.cosh(1)), 1)
|
||||
check(Math.atanh(Math.sinh(2) / Math.cosh(2)), 2)
|
||||
check(0, Math.atanh(Math.sinh(0) / Math.cosh(0)))
|
||||
check(1, Math.atanh(Math.sinh(1) / Math.cosh(1)))
|
||||
check(2, Math.atanh(Math.sinh(2) / Math.cosh(2)))
|
||||
assert_raise(Errno::EDOM, Errno::ERANGE) { Math.atanh(-1) }
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue