X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/7637cd0734b6068e23bb0804d6e84410ea017c73..b57c8994d18dca212b1e1f9547c24fffd7deff90:/lib/Math/Trig.t diff --git a/lib/Math/Trig.t b/lib/Math/Trig.t index 9febacc..7b0d7cf 100755 --- a/lib/Math/Trig.t +++ b/lib/Math/Trig.t @@ -26,10 +26,10 @@ BEGIN { } } -plan(tests => 135); +plan(tests => 153); -use Math::Trig 1.09; -use Math::Trig 1.09 qw(Inf); +use Math::Trig 1.13; +use Math::Trig 1.13 qw(:pi Inf); my $pip2 = pi / 2; @@ -311,10 +311,11 @@ print "# Infinity\n"; my $BigDouble = 1e40; -local $SIG{FPE} = { }; # E.g. netbsd-alpha core dumps on Inf arith +# E.g. netbsd-alpha core dumps on Inf arith without this. +local $SIG{FPE} = { }; ok(Inf() > $BigDouble); # This passes in netbsd-alpha. -ok(Inf() + $BigDouble > $BigDouble); # This coredumps. +ok(Inf() + $BigDouble > $BigDouble); # This coredumps in netbsd-alpha. ok(Inf() + $BigDouble == Inf()); ok(Inf() - $BigDouble > $BigDouble); ok(Inf() - $BigDouble == Inf()); @@ -363,4 +364,30 @@ cmp_ok(csch(-1e5), '==', 0); cmp_ok(tanh(-1e5), '==', -1); cmp_ok(coth(-1e5), '==', -1); +print "# great_circle_distance with small angles\n"; + +for my $e (qw(1e-2 1e-3 1e-4 1e-5)) { + # Can't assume == 0 because of floating point fuzz, + # but let's hope for at least < $e. + cmp_ok(great_circle_distance(0, $e, 0, $e), '<', $e); +} + +print "# asin_real, acos_real\n"; + +is(acos_real(-2.0), pi); +is(acos_real(-1.0), pi); +is(acos_real(-0.5), acos(-0.5)); +is(acos_real( 0.0), acos( 0.0)); +is(acos_real( 0.5), acos( 0.5)); +is(acos_real( 1.0), 0); +is(acos_real( 2.0), 0); + +is(asin_real(-2.0), -&pip2); +is(asin_real(-1.0), -&pip2); +is(asin_real(-0.5), asin(-0.5)); +is(asin_real( 0.0), asin( 0.0)); +is(asin_real( 0.5), asin( 0.5)); +is(asin_real( 1.0), pip2); +is(asin_real( 2.0), pip2); + # eof