Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Actual trig tests generated by running the "Remove unneeded inverse s…
…ub test, and use a better information string for the surviving equivalent test." patch.
  • Loading branch information
colomon committed Aug 8, 2011
1 parent 7bf42b2 commit 5c6b8e3
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 99 deletions.
118 changes: 59 additions & 59 deletions S32-trig/atan2.t
Expand Up @@ -87,181 +87,181 @@ is_approx(atan2(-4, -4), -3 * pi / 4, "atan2(-4, -4) is -3pi / 4");

{
# Num tests
is_approx(atan2((1).Num), 0.785398163397448, "atan2(Num)");
is_approx(atan2((-1).Num), -0.785398163397448, "atan2(Num)");
}

{
# Num vs Num tests
is_approx((-0.1).Num.atan2((100).Num), -0.000999999666666867, "Num.atan2(Num)");
is_approx(atan2((0.1).Num, (1).Num), 0.099668652491162, "atan2(Num, Num)");
is_approx((-10).Num.atan2((100).Num), -0.099668652491162, "Num.atan2(Num)");
is_approx(atan2((1).Num, (-10).Num), 3.04192400109863, "atan2(Num, Num)");
}

{
# Num vs Rat tests
is_approx((-100).Num.atan2((-10).Rat), -1.67046497928606, "Num.atan2(Rat)");
is_approx(atan2((-100).Num, (100).Rat), -0.785398163397448, "atan2(Num, Rat)");
is_approx((100).Num.atan2((-0.1).Rat(1e-9)), 1.57179632646156, "Num.atan2(Rat)");
is_approx(atan2((-0.1).Num, (0.1).Rat(1e-9)), -0.785398163397448, "atan2(Num, Rat)");
}

{
# Num vs Int tests
is_approx((-10).Num.atan2((10).Int), -0.785398163397448, "Num.atan2(Int)");
is_approx(atan2((-10).Num, (-10).Int), -2.35619449019234, "atan2(Num, Int)");
is_approx((-0.1).Num.atan2((-10).Int), -3.13159298690313, "Num.atan2(Int)");
is_approx(atan2((-1).Num, (100).Int), -0.00999966668666524, "atan2(Num, Int)");
}

{
# Num vs Str tests
is_approx((-1).Num.atan2((100).Str), -0.00999966668666524, "Num.atan2(Str)");
is_approx(atan2((-10).Num, (-0.1).Str), -1.58079599348156, "atan2(Num, Str)");
is_approx((1).Num.atan2((100).Str), 0.00999966668666524, "Num.atan2(Str)");
is_approx(atan2((-1).Num, (0.1).Str), -1.47112767430373, "atan2(Num, Str)");
}

{
# Num vs DifferentReal tests
is_approx((-100).Num.atan2(DifferentReal.new(-0.1)), -1.57179632646156, "Num.atan2(DifferentReal)");
is_approx(atan2((-100).Num, DifferentReal.new(-1)), -1.58079599348156, "atan2(Num, DifferentReal)");
is_approx((0.1).Num.atan2(DifferentReal.new(1)), 0.099668652491162, "Num.atan2(DifferentReal)");
is_approx(atan2((-10).Num, DifferentReal.new(1)), -1.47112767430373, "atan2(Num, DifferentReal)");
}

{
# Rat tests
is_approx((-0.1).Rat.atan2, -0.099668652491162, "Rat.atan2");
is_approx(atan2((-1).Rat), -0.785398163397448, "atan2(Rat)");
is_approx((-0.1).Rat(1e-9).atan2, -0.099668652491162, "Rat.atan2");
is_approx(atan2((-0.1).Rat(1e-9)), -0.099668652491162, "atan2(Rat)");
}

{
# Rat vs Num tests
is_approx((-1).Rat.atan2((-0.1).Num), -1.67046497928606, "Rat.atan2(Num)");
is_approx(atan2((-100).Rat, (-1).Num), -1.58079599348156, "atan2(Rat, Num)");
is_approx((0.1).Rat(1e-9).atan2((100).Num), 0.000999999666666867, "Rat.atan2(Num)");
is_approx(atan2((0.1).Rat(1e-9), (-100).Num), 3.14059265392313, "atan2(Rat, Num)");
}

{
# Rat vs Rat tests
is_approx((-100).Rat.atan2((1).Rat), -1.56079666010823, "Rat.atan2(Rat)");
is_approx(atan2((-0.1).Rat, (-1).Rat), -3.04192400109863, "atan2(Rat, Rat)");
is_approx((-1).Rat(1e-9).atan2((10).Rat(1e-9)), -0.099668652491162, "Rat.atan2(Rat)");
is_approx(atan2((10).Rat(1e-9), (0.1).Rat(1e-9)), 1.56079666010823, "atan2(Rat, Rat)");
}

{
# Rat vs Int tests
is_approx((-0.1).Rat.atan2((-1).Int), -3.04192400109863, "Rat.atan2(Int)");
is_approx(atan2((-0.1).Rat, (1).Int), -0.099668652491162, "atan2(Rat, Int)");
is_approx((100).Rat(1e-9).atan2((-1).Int), 1.58079599348156, "Rat.atan2(Int)");
is_approx(atan2((1).Rat(1e-9), (1).Int), 0.785398163397448, "atan2(Rat, Int)");
}

{
# Rat vs Str tests
is_approx((-0.1).Rat.atan2((1).Str), -0.099668652491162, "Rat.atan2(Str)");
is_approx(atan2((0.1).Rat, (10).Str), 0.00999966668666524, "atan2(Rat, Str)");
is_approx((-100).Rat(1e-9).atan2((-1).Str), -1.58079599348156, "Rat.atan2(Str)");
is_approx(atan2((-100).Rat(1e-9), (0.1).Str), -1.56979632712823, "atan2(Rat, Str)");
}

{
# Rat vs DifferentReal tests
is_approx((-10).Rat.atan2(DifferentReal.new(10)), -0.785398163397448, "Rat.atan2(DifferentReal)");
is_approx(atan2((0.1).Rat, DifferentReal.new(100)), 0.000999999666666867, "atan2(Rat, DifferentReal)");
is_approx((100).Rat(1e-9).atan2(DifferentReal.new(100)), 0.785398163397448, "Rat.atan2(DifferentReal)");
is_approx(atan2((-0.1).Rat(1e-9), DifferentReal.new(1)), -0.099668652491162, "atan2(Rat, DifferentReal)");
}

{
# Int tests
is_approx((1).Int.atan2, 0.785398163397448, "Int.atan2");
is_approx(atan2((10).Int), 1.47112767430373, "atan2(Int)");
is_approx((-100).Int.atan2, -1.56079666010823, "Int.atan2");
is_approx(atan2((-10).Int), -1.47112767430373, "atan2(Int)");
}

{
# Int vs Num tests
is_approx((-100).Int.atan2((-100).Num), -2.35619449019234, "Int.atan2(Num)");
is_approx(atan2((-10).Int, (0.1).Num), -1.56079666010823, "atan2(Int, Num)");
is_approx((-100).Int.atan2((10).Num), -1.47112767430373, "Int.atan2(Num)");
is_approx(atan2((-10).Int, (-0.1).Num), -1.58079599348156, "atan2(Int, Num)");
}

{
# Int vs Rat tests
is_approx((10).Int.atan2((100).Rat), 0.099668652491162, "Int.atan2(Rat)");
is_approx(atan2((100).Int, (-100).Rat), 2.35619449019234, "atan2(Int, Rat)");
is_approx((10).Int.atan2((100).Rat(1e-9)), 0.099668652491162, "Int.atan2(Rat)");
is_approx(atan2((-100).Int, (-0.1).Rat(1e-9)), -1.57179632646156, "atan2(Int, Rat)");
}

{
# Int vs Int tests
is_approx((1).Int.atan2((-1).Int), 2.35619449019234, "Int.atan2(Int)");
is_approx(atan2((1).Int, (1).Int), 0.785398163397448, "atan2(Int, Int)");
is_approx((1).Int.atan2((10).Int), 0.099668652491162, "Int.atan2(Int)");
is_approx(atan2((-100).Int, (100).Int), -0.785398163397448, "atan2(Int, Int)");
}

{
# Int vs Str tests
is_approx((1).Int.atan2((10).Str), 0.099668652491162, "Int.atan2(Str)");
is_approx(atan2((1).Int, (0.1).Str), 1.47112767430373, "atan2(Int, Str)");
is_approx((1).Int.atan2((-0.1).Str), 1.67046497928606, "Int.atan2(Str)");
is_approx(atan2((-1).Int, (-10).Str), -3.04192400109863, "atan2(Int, Str)");
}

{
# Int vs DifferentReal tests
is_approx((1).Int.atan2(DifferentReal.new(-10)), 3.04192400109863, "Int.atan2(DifferentReal)");
is_approx(atan2((-100).Int, DifferentReal.new(0.1)), -1.56979632712823, "atan2(Int, DifferentReal)");
is_approx((-1).Int.atan2(DifferentReal.new(-0.1)), -1.67046497928606, "Int.atan2(DifferentReal)");
is_approx(atan2((-1).Int, DifferentReal.new(-1)), -2.35619449019234, "atan2(Int, DifferentReal)");
}

{
# Str tests
is_approx((10).Str.atan2, 1.47112767430373, "Str.atan2");
is_approx(atan2((0.1).Str), 0.099668652491162, "atan2(Str)");
is_approx((0.1).Str.atan2, 0.099668652491162, "Str.atan2");
is_approx(atan2((-100).Str), -1.56079666010823, "atan2(Str)");
}

{
# Str vs Num tests
is_approx((-0.1).Str.atan2((10).Num), -0.00999966668666524, "Str.atan2(Num)");
is_approx(atan2((10).Str, (100).Num), 0.099668652491162, "atan2(Str, Num)");
is_approx((-100).Str.atan2((100).Num), -0.785398163397448, "Str.atan2(Num)");
is_approx(atan2((-0.1).Str, (-1).Num), -3.04192400109863, "atan2(Str, Num)");
}

{
# Str vs Rat tests
is_approx((-100).Str.atan2((0.1).Rat), -1.56979632712823, "Str.atan2(Rat)");
is_approx(atan2((-10).Str, (-1).Rat), -1.67046497928606, "atan2(Str, Rat)");
is_approx((0.1).Str.atan2((-0.1).Rat(1e-9)), 2.35619449019234, "Str.atan2(Rat)");
is_approx(atan2((-10).Str, (-100).Rat(1e-9)), -3.04192400109863, "atan2(Str, Rat)");
}

{
# Str vs Int tests
is_approx((1).Str.atan2((-1).Int), 2.35619449019234, "Str.atan2(Int)");
is_approx(atan2((10).Str, (-100).Int), 3.04192400109863, "atan2(Str, Int)");
is_approx((0.1).Str.atan2((-100).Int), 3.14059265392313, "Str.atan2(Int)");
is_approx(atan2((1).Str, (-1).Int), 2.35619449019234, "atan2(Str, Int)");
}

{
# Str vs Str tests
is_approx((-100).Str.atan2((-100).Str), -2.35619449019234, "Str.atan2(Str)");
is_approx(atan2((10).Str, (-100).Str), 3.04192400109863, "atan2(Str, Str)");
is_approx((10).Str.atan2((1).Str), 1.47112767430373, "Str.atan2(Str)");
is_approx(atan2((100).Str, (0.1).Str), 1.56979632712823, "atan2(Str, Str)");
}

{
# Str vs DifferentReal tests
is_approx((0.1).Str.atan2(DifferentReal.new(-0.1)), 2.35619449019234, "Str.atan2(DifferentReal)");
is_approx(atan2((-1).Str, DifferentReal.new(-100)), -3.13159298690313, "atan2(Str, DifferentReal)");
is_approx((10).Str.atan2(DifferentReal.new(100)), 0.099668652491162, "Str.atan2(DifferentReal)");
is_approx(atan2((0.1).Str, DifferentReal.new(100)), 0.000999999666666867, "atan2(Str, DifferentReal)");
}

{
# DifferentReal tests
is_approx(DifferentReal.new(0.1).atan2, 0.099668652491162, "DifferentReal.atan2");
is_approx(atan2(DifferentReal.new(100)), 1.56079666010823, "atan2(DifferentReal)");
is_approx(DifferentReal.new(-0.1).atan2, -0.099668652491162, "DifferentReal.atan2");
is_approx(atan2(DifferentReal.new(0.1)), 0.099668652491162, "atan2(DifferentReal)");
}

{
# DifferentReal vs Num tests
is_approx(DifferentReal.new(1).atan2((-0.1).Num), 1.67046497928606, "DifferentReal.atan2(Num)");
is_approx(atan2(DifferentReal.new(0.1), (10).Num), 0.00999966668666524, "atan2(DifferentReal, Num)");
is_approx(DifferentReal.new(0.1).atan2((-10).Num), 3.13159298690313, "DifferentReal.atan2(Num)");
is_approx(atan2(DifferentReal.new(10), (100).Num), 0.099668652491162, "atan2(DifferentReal, Num)");
}

{
# DifferentReal vs Rat tests
is_approx(DifferentReal.new(-10).atan2((-0.1).Rat), -1.58079599348156, "DifferentReal.atan2(Rat)");
is_approx(atan2(DifferentReal.new(1), (10).Rat), 0.099668652491162, "atan2(DifferentReal, Rat)");
is_approx(DifferentReal.new(-1).atan2((-10).Rat(1e-9)), -3.04192400109863, "DifferentReal.atan2(Rat)");
is_approx(atan2(DifferentReal.new(100), (-0.1).Rat(1e-9)), 1.57179632646156, "atan2(DifferentReal, Rat)");
}

{
# DifferentReal vs Int tests
is_approx(DifferentReal.new(0.1).atan2((1).Int), 0.099668652491162, "DifferentReal.atan2(Int)");
is_approx(atan2(DifferentReal.new(-100), (-1).Int), -1.58079599348156, "atan2(DifferentReal, Int)");
is_approx(DifferentReal.new(10).atan2((-10).Int), 2.35619449019234, "DifferentReal.atan2(Int)");
is_approx(atan2(DifferentReal.new(-1), (1).Int), -0.785398163397448, "atan2(DifferentReal, Int)");
}

{
# DifferentReal vs Str tests
is_approx(DifferentReal.new(-10).atan2((-10).Str), -2.35619449019234, "DifferentReal.atan2(Str)");
is_approx(atan2(DifferentReal.new(100), (-100).Str), 2.35619449019234, "atan2(DifferentReal, Str)");
is_approx(DifferentReal.new(0.1).atan2((100).Str), 0.000999999666666867, "DifferentReal.atan2(Str)");
is_approx(atan2(DifferentReal.new(-100), (1).Str), -1.56079666010823, "atan2(DifferentReal, Str)");
}

{
# DifferentReal vs DifferentReal tests
is_approx(DifferentReal.new(-0.1).atan2(DifferentReal.new(-1)), -3.04192400109863, "DifferentReal.atan2(DifferentReal)");
is_approx(atan2(DifferentReal.new(10), DifferentReal.new(100)), 0.099668652491162, "atan2(DifferentReal, DifferentReal)");
is_approx(DifferentReal.new(-1).atan2(DifferentReal.new(-100)), -3.13159298690313, "DifferentReal.atan2(DifferentReal)");
is_approx(atan2(DifferentReal.new(100), DifferentReal.new(-10)), 1.67046497928606, "atan2(DifferentReal, DifferentReal)");
}

done;
Expand Down
4 changes: 1 addition & 3 deletions S32-trig/cos.t
Expand Up @@ -140,10 +140,8 @@ for @cosines -> $angle

# Num.acos(Complex) tests -- thorough
for ($desired-result + 0i, $desired-result + .5i, $desired-result + 2i) -> $z {
is_approx(cos(acos($z)), $z,
"acos(Complex) - {$angle.key()}");
is_approx($z.acos.cos, $z,
"Complex.acos - {$angle.key()}");
"Complex.acos - $z");
}
}

Expand Down
4 changes: 1 addition & 3 deletions S32-trig/cosec.t
Expand Up @@ -140,10 +140,8 @@ for @sines -> $angle

# Num.acosec(Complex) tests -- thorough
for ($desired-result + 0i, $desired-result + .5i, $desired-result + 2i) -> $z {
is_approx(cosec(acosec($z)), $z,
"acosec(Complex) - {$angle.key()}");
is_approx($z.acosec.cosec, $z,
"Complex.acosec - {$angle.key()}");
"Complex.acosec - $z");
}
}

Expand Down
4 changes: 1 addition & 3 deletions S32-trig/cosech.t
Expand Up @@ -140,10 +140,8 @@ for @sines -> $angle

# Num.acosech(Complex) tests -- thorough
for ($desired-result + 0i, $desired-result + .5i, $desired-result + 2i) -> $z {
is_approx(cosech(acosech($z)), $z,
"acosech(Complex) - {$angle.key()}");
is_approx($z.acosech.cosech, $z,
"Complex.acosech - {$angle.key()}");
"Complex.acosech - $z");
}
}

Expand Down
4 changes: 1 addition & 3 deletions S32-trig/cosh.t
Expand Up @@ -140,10 +140,8 @@ for @coshes -> $angle

# Num.acosh(Complex) tests -- thorough
for ($desired-result + 0i, $desired-result + .5i, $desired-result + 2i) -> $z {
is_approx(cosh(acosh($z)), $z,
"acosh(Complex) - {$angle.key()}");
is_approx($z.acosh.cosh, $z,
"Complex.acosh - {$angle.key()}");
"Complex.acosh - $z");
}
}

Expand Down
8 changes: 3 additions & 5 deletions S32-trig/cotan.t
Expand Up @@ -116,8 +116,8 @@ for @sines -> $angle

{
# NotComplex tests
is_approx(NotComplex.new(3.92699081702367 + 2i).cotan, 0.0366189934735888 - 0.999329299736401i, "NotComplex.cotan - 3.92699081702367 + 2i");
is_approx(cotan(NotComplex.new(4.7123889804284 + 2i)), -3.08850574993024e-12 - 0.964027580075817i, "cotan(NotComplex) - 4.7123889804284 + 2i");
is_approx(NotComplex.new(3.92699081702367 + 2i).cotan, 0.036618993473589 - 0.999329299736401i, "NotComplex.cotan - 3.92699081702367 + 2i");
is_approx(cotan(NotComplex.new(4.7123889804284 + 2i)), -3.08850574993026e-12 - 0.964027580075817i, "cotan(NotComplex) - 4.7123889804284 + 2i");
}

{
Expand All @@ -140,10 +140,8 @@ for @sines -> $angle

# Num.acotan(Complex) tests -- thorough
for ($desired-result + 0i, $desired-result + .5i, $desired-result + 2i) -> $z {
is_approx(cotan(acotan($z)), $z,
"acotan(Complex) - {$angle.key()}");
is_approx($z.acotan.cotan, $z,
"Complex.acotan - {$angle.key()}");
"Complex.acotan - $z");
}
}

Expand Down
4 changes: 1 addition & 3 deletions S32-trig/cotanh.t
Expand Up @@ -140,10 +140,8 @@ for @sines -> $angle

# Num.acotanh(Complex) tests -- thorough
for ($desired-result + 0i, $desired-result + .5i, $desired-result + 2i) -> $z {
is_approx(cotanh(acotanh($z)), $z,
"acotanh(Complex) - {$angle.key()}");
is_approx($z.acotanh.cotanh, $z,
"Complex.acotanh - {$angle.key()}");
"Complex.acotanh - $z");
}
}

Expand Down
4 changes: 1 addition & 3 deletions S32-trig/sec.t
Expand Up @@ -140,10 +140,8 @@ for @cosines -> $angle

# Num.asec(Complex) tests -- thorough
for ($desired-result + 0i, $desired-result + .5i, $desired-result + 2i) -> $z {
is_approx(sec(asec($z)), $z,
"asec(Complex) - {$angle.key()}");
is_approx($z.asec.sec, $z,
"Complex.asec - {$angle.key()}");
"Complex.asec - $z");
}
}

Expand Down
4 changes: 1 addition & 3 deletions S32-trig/sech.t
Expand Up @@ -140,10 +140,8 @@ for @cosines -> $angle

# Num.asech(Complex) tests -- thorough
for ($desired-result + 0i, $desired-result + .5i, $desired-result + 2i) -> $z {
is_approx(sech(asech($z)), $z,
"asech(Complex) - {$angle.key()}");
is_approx($z.asech.sech, $z,
"Complex.asech - {$angle.key()}");
"Complex.asech - $z");
}
}

Expand Down
4 changes: 1 addition & 3 deletions S32-trig/sin.t
Expand Up @@ -140,10 +140,8 @@ for @sines -> $angle

# Num.asin(Complex) tests -- thorough
for ($desired-result + 0i, $desired-result + .5i, $desired-result + 2i) -> $z {
is_approx(sin(asin($z)), $z,
"asin(Complex) - {$angle.key()}");
is_approx($z.asin.sin, $z,
"Complex.asin - {$angle.key()}");
"Complex.asin - $z");
}
}

Expand Down
4 changes: 1 addition & 3 deletions S32-trig/sinh.t
Expand Up @@ -140,10 +140,8 @@ for @sinhes -> $angle

# Num.asinh(Complex) tests -- thorough
for ($desired-result + 0i, $desired-result + .5i, $desired-result + 2i) -> $z {
is_approx(sinh(asinh($z)), $z,
"asinh(Complex) - {$angle.key()}");
is_approx($z.asinh.sinh, $z,
"Complex.asinh - {$angle.key()}");
"Complex.asinh - $z");
}
}

Expand Down
8 changes: 3 additions & 5 deletions S32-trig/tan.t
Expand Up @@ -116,8 +116,8 @@ for @sines -> $angle

{
# NotComplex tests
is_approx(NotComplex.new(2.3561944902142 + 2i).tan, -0.0366189934736278 + 0.999329299737467i, "NotComplex.tan - 2.3561944902142 + 2i");
is_approx(tan(NotComplex.new(3.14159265361894 + 2i)), 2.05899337486383e-12 + 0.964027580075817i, "tan(NotComplex) - 3.14159265361894 + 2i");
is_approx(NotComplex.new(2.3561944902142 + 2i).tan, -0.0366189934736279 + 0.999329299737467i, "NotComplex.tan - 2.3561944902142 + 2i");
is_approx(tan(NotComplex.new(3.14159265361894 + 2i)), 2.05899337486384e-12 + 0.964027580075817i, "tan(NotComplex) - 3.14159265361894 + 2i");
}

{
Expand All @@ -140,10 +140,8 @@ for @sines -> $angle

# Num.atan(Complex) tests -- thorough
for ($desired-result + 0i, $desired-result + .5i, $desired-result + 2i) -> $z {
is_approx(tan(atan($z)), $z,
"atan(Complex) - {$angle.key()}");
is_approx($z.atan.tan, $z,
"Complex.atan - {$angle.key()}");
"Complex.atan - $z");
}
}

Expand Down

0 comments on commit 5c6b8e3

Please sign in to comment.