# Actual-expected argument ordering for test\_math.rb

**URL:** <https://www.ruby-forum.com/t/actual-expected-argument-ordering-for-test-math-rb/129048>\
**Category:** Development\
**Created:** [February 13, 2008, 8:15pm UTC](https://www.ruby-forum.com/t/actual-expected-argument-ordering-for-test-math-rb/129048 "2008-02-13T20:15:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sugie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@sugie](https://www.ruby-forum.com/u/sugie)\
**Post date:** [February 13, 2008, 8:15pm UTC](https://www.ruby-forum.com/t/actual-expected-argument-ordering-for-test-math-rb/129048/1 "2008-02-13T20:15:04Z")

</div>

e$B:XF#$H?=$7$^$9!#e(B

e$B:G6aDI2C$5$l$?e(Btest\_math.rbe$B$NCf$G!"0z?t$N=g$,e(B (expected,  
actual, …) e$B$He(B  
e$B$J$k$Y$-$H$3$m$,5,B’@-$J$/JB$s$G$$$k$h$&$J$N$G!"D\>$7$F$\_$^$7$?!#e(B

# Index: test/ruby/test\_math.rb

— test/ruby/test\_math.rb (revision 15464)  
+++ test/ruby/test\_math.rb (working copy)  
@@ -6,32 +6,32 @@  
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 @@  
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
