Skip to content

Commit

Permalink
Remove TrigTestSupport.pm.
Browse files Browse the repository at this point in the history
  • Loading branch information
colomon committed Jul 27, 2011
1 parent aea78b8 commit 59b5e94
Show file tree
Hide file tree
Showing 16 changed files with 605 additions and 197 deletions.
210 changes: 120 additions & 90 deletions S32-trig/atan2.t

Large diffs are not rendered by default.

38 changes: 34 additions & 4 deletions S32-trig/cos.t
Expand Up @@ -4,14 +4,44 @@

use v6;
use Test;
BEGIN { @*INC.push("t/spec/packages/") };
use TrigTestSupport;

sub degrees-to-radians($x) {
$x * (312689/99532) / 180;
}

my @sines = (
degrees-to-radians(-360) => 0,
degrees-to-radians(135 - 360) => 1/2*sqrt(2),
degrees-to-radians(330 - 360) => -0.5,
degrees-to-radians(0) => 0,
degrees-to-radians(30) => 0.5,
degrees-to-radians(45) => 1/2*sqrt(2),
degrees-to-radians(90) => 1,
degrees-to-radians(135) => 1/2*sqrt(2),
degrees-to-radians(180) => 0,
degrees-to-radians(225) => -1/2*sqrt(2),
degrees-to-radians(270) => -1,
degrees-to-radians(315) => -1/2*sqrt(2),
degrees-to-radians(360) => 0,
degrees-to-radians(30 + 360) => 0.5,
degrees-to-radians(225 + 360) => -1/2*sqrt(2),
degrees-to-radians(720) => 0
);

my @cosines = @sines.map({; $_.key - degrees-to-radians(90) => $_.value });

my @sinhes = @sines.grep({ $_.key < degrees-to-radians(500) }).map({; $_.key =>
(exp($_.key) - exp(-$_.key)) / 2.0 });

my @coshes = @sines.grep({ $_.key < degrees-to-radians(500) }).map({; $_.key =>
(exp($_.key) + exp(-$_.key)) / 2.0 });



# cos tests

my $iter_count = 0;
for TrigTest::cosines() -> $angle
for @cosines -> $angle
{

my $desired-result = $angle.value;
Expand Down Expand Up @@ -97,7 +127,7 @@ is_approx(cos(:x((2.3561944902142).Str)), -0.707106781186548, "cos(:x(Str)) - 2.

# acos tests

for TrigTest::cosines() -> $angle
for @cosines -> $angle
{

my $desired-result = $angle.value;
Expand Down
38 changes: 34 additions & 4 deletions S32-trig/cosec.t
Expand Up @@ -4,14 +4,44 @@

use v6;
use Test;
BEGIN { @*INC.push("t/spec/packages/") };
use TrigTestSupport;

sub degrees-to-radians($x) {
$x * (312689/99532) / 180;
}

my @sines = (
degrees-to-radians(-360) => 0,
degrees-to-radians(135 - 360) => 1/2*sqrt(2),
degrees-to-radians(330 - 360) => -0.5,
degrees-to-radians(0) => 0,
degrees-to-radians(30) => 0.5,
degrees-to-radians(45) => 1/2*sqrt(2),
degrees-to-radians(90) => 1,
degrees-to-radians(135) => 1/2*sqrt(2),
degrees-to-radians(180) => 0,
degrees-to-radians(225) => -1/2*sqrt(2),
degrees-to-radians(270) => -1,
degrees-to-radians(315) => -1/2*sqrt(2),
degrees-to-radians(360) => 0,
degrees-to-radians(30 + 360) => 0.5,
degrees-to-radians(225 + 360) => -1/2*sqrt(2),
degrees-to-radians(720) => 0
);

my @cosines = @sines.map({; $_.key - degrees-to-radians(90) => $_.value });

my @sinhes = @sines.grep({ $_.key < degrees-to-radians(500) }).map({; $_.key =>
(exp($_.key) - exp(-$_.key)) / 2.0 });

my @coshes = @sines.grep({ $_.key < degrees-to-radians(500) }).map({; $_.key =>
(exp($_.key) + exp(-$_.key)) / 2.0 });



# cosec tests

my $iter_count = 0;
for TrigTest::sines() -> $angle
for @sines -> $angle
{
next if abs(sin($angle.key())) < 1e-6;
my $desired-result = 1.0 / sin($angle.key());
Expand Down Expand Up @@ -97,7 +127,7 @@ is_approx(cosec(:x((6.80678408284103).Str)), 1.99999999978126, "cosec(:x(Str)) -

# acosec tests

for TrigTest::sines() -> $angle
for @sines -> $angle
{
next if abs(sin($angle.key())) < 1e-6;
my $desired-result = 1.0 / sin($angle.key());
Expand Down
38 changes: 34 additions & 4 deletions S32-trig/cosech.t
Expand Up @@ -4,14 +4,44 @@

use v6;
use Test;
BEGIN { @*INC.push("t/spec/packages/") };
use TrigTestSupport;

sub degrees-to-radians($x) {
$x * (312689/99532) / 180;
}

my @sines = (
degrees-to-radians(-360) => 0,
degrees-to-radians(135 - 360) => 1/2*sqrt(2),
degrees-to-radians(330 - 360) => -0.5,
degrees-to-radians(0) => 0,
degrees-to-radians(30) => 0.5,
degrees-to-radians(45) => 1/2*sqrt(2),
degrees-to-radians(90) => 1,
degrees-to-radians(135) => 1/2*sqrt(2),
degrees-to-radians(180) => 0,
degrees-to-radians(225) => -1/2*sqrt(2),
degrees-to-radians(270) => -1,
degrees-to-radians(315) => -1/2*sqrt(2),
degrees-to-radians(360) => 0,
degrees-to-radians(30 + 360) => 0.5,
degrees-to-radians(225 + 360) => -1/2*sqrt(2),
degrees-to-radians(720) => 0
);

my @cosines = @sines.map({; $_.key - degrees-to-radians(90) => $_.value });

my @sinhes = @sines.grep({ $_.key < degrees-to-radians(500) }).map({; $_.key =>
(exp($_.key) - exp(-$_.key)) / 2.0 });

my @coshes = @sines.grep({ $_.key < degrees-to-radians(500) }).map({; $_.key =>
(exp($_.key) + exp(-$_.key)) / 2.0 });



# cosech tests

my $iter_count = 0;
for TrigTest::sines() -> $angle
for @sines -> $angle
{
next if abs(sinh($angle.key())) < 1e-6;
my $desired-result = 1.0 / sinh($angle.key());
Expand Down Expand Up @@ -97,7 +127,7 @@ is_approx(cosech(:x((4.7123889804284).Str)), 0.0179680320529917, "cosech(:x(Str)

# acosech tests

for TrigTest::sines() -> $angle
for @sines -> $angle
{
next if abs(sinh($angle.key())) < 1e-6;
my $desired-result = 1.0 / sinh($angle.key());
Expand Down
38 changes: 34 additions & 4 deletions S32-trig/cosh.t
Expand Up @@ -4,14 +4,44 @@

use v6;
use Test;
BEGIN { @*INC.push("t/spec/packages/") };
use TrigTestSupport;

sub degrees-to-radians($x) {
$x * (312689/99532) / 180;
}

my @sines = (
degrees-to-radians(-360) => 0,
degrees-to-radians(135 - 360) => 1/2*sqrt(2),
degrees-to-radians(330 - 360) => -0.5,
degrees-to-radians(0) => 0,
degrees-to-radians(30) => 0.5,
degrees-to-radians(45) => 1/2*sqrt(2),
degrees-to-radians(90) => 1,
degrees-to-radians(135) => 1/2*sqrt(2),
degrees-to-radians(180) => 0,
degrees-to-radians(225) => -1/2*sqrt(2),
degrees-to-radians(270) => -1,
degrees-to-radians(315) => -1/2*sqrt(2),
degrees-to-radians(360) => 0,
degrees-to-radians(30 + 360) => 0.5,
degrees-to-radians(225 + 360) => -1/2*sqrt(2),
degrees-to-radians(720) => 0
);

my @cosines = @sines.map({; $_.key - degrees-to-radians(90) => $_.value });

my @sinhes = @sines.grep({ $_.key < degrees-to-radians(500) }).map({; $_.key =>
(exp($_.key) - exp(-$_.key)) / 2.0 });

my @coshes = @sines.grep({ $_.key < degrees-to-radians(500) }).map({; $_.key =>
(exp($_.key) + exp(-$_.key)) / 2.0 });



# cosh tests

my $iter_count = 0;
for TrigTest::coshes() -> $angle
for @coshes -> $angle
{

my $desired-result = $angle.value;
Expand Down Expand Up @@ -97,7 +127,7 @@ is_approx(cosh(:x((3.92699081702367).Str)), 25.3868611932849, "cosh(:x(Str)) - 3

# acosh tests

for TrigTest::coshes() -> $angle
for @coshes -> $angle
{

my $desired-result = $angle.value;
Expand Down
38 changes: 34 additions & 4 deletions S32-trig/cotan.t
Expand Up @@ -4,14 +4,44 @@

use v6;
use Test;
BEGIN { @*INC.push("t/spec/packages/") };
use TrigTestSupport;

sub degrees-to-radians($x) {
$x * (312689/99532) / 180;
}

my @sines = (
degrees-to-radians(-360) => 0,
degrees-to-radians(135 - 360) => 1/2*sqrt(2),
degrees-to-radians(330 - 360) => -0.5,
degrees-to-radians(0) => 0,
degrees-to-radians(30) => 0.5,
degrees-to-radians(45) => 1/2*sqrt(2),
degrees-to-radians(90) => 1,
degrees-to-radians(135) => 1/2*sqrt(2),
degrees-to-radians(180) => 0,
degrees-to-radians(225) => -1/2*sqrt(2),
degrees-to-radians(270) => -1,
degrees-to-radians(315) => -1/2*sqrt(2),
degrees-to-radians(360) => 0,
degrees-to-radians(30 + 360) => 0.5,
degrees-to-radians(225 + 360) => -1/2*sqrt(2),
degrees-to-radians(720) => 0
);

my @cosines = @sines.map({; $_.key - degrees-to-radians(90) => $_.value });

my @sinhes = @sines.grep({ $_.key < degrees-to-radians(500) }).map({; $_.key =>
(exp($_.key) - exp(-$_.key)) / 2.0 });

my @coshes = @sines.grep({ $_.key < degrees-to-radians(500) }).map({; $_.key =>
(exp($_.key) + exp(-$_.key)) / 2.0 });



# cotan tests

my $iter_count = 0;
for TrigTest::sines() -> $angle
for @sines -> $angle
{
next if abs(sin($angle.key())) < 1e-6;
my $desired-result = cos($angle.key()) / sin($angle.key());
Expand Down Expand Up @@ -97,7 +127,7 @@ is_approx(cotan(:x((6.80678408284103).Str)), 1.7320508073163, "cotan(:x(Str)) -

# acotan tests

for TrigTest::sines() -> $angle
for @sines -> $angle
{
next if abs(sin($angle.key())) < 1e-6;
my $desired-result = cos($angle.key()) / sin($angle.key());
Expand Down
38 changes: 34 additions & 4 deletions S32-trig/cotanh.t
Expand Up @@ -4,14 +4,44 @@

use v6;
use Test;
BEGIN { @*INC.push("t/spec/packages/") };
use TrigTestSupport;

sub degrees-to-radians($x) {
$x * (312689/99532) / 180;
}

my @sines = (
degrees-to-radians(-360) => 0,
degrees-to-radians(135 - 360) => 1/2*sqrt(2),
degrees-to-radians(330 - 360) => -0.5,
degrees-to-radians(0) => 0,
degrees-to-radians(30) => 0.5,
degrees-to-radians(45) => 1/2*sqrt(2),
degrees-to-radians(90) => 1,
degrees-to-radians(135) => 1/2*sqrt(2),
degrees-to-radians(180) => 0,
degrees-to-radians(225) => -1/2*sqrt(2),
degrees-to-radians(270) => -1,
degrees-to-radians(315) => -1/2*sqrt(2),
degrees-to-radians(360) => 0,
degrees-to-radians(30 + 360) => 0.5,
degrees-to-radians(225 + 360) => -1/2*sqrt(2),
degrees-to-radians(720) => 0
);

my @cosines = @sines.map({; $_.key - degrees-to-radians(90) => $_.value });

my @sinhes = @sines.grep({ $_.key < degrees-to-radians(500) }).map({; $_.key =>
(exp($_.key) - exp(-$_.key)) / 2.0 });

my @coshes = @sines.grep({ $_.key < degrees-to-radians(500) }).map({; $_.key =>
(exp($_.key) + exp(-$_.key)) / 2.0 });



# cotanh tests

my $iter_count = 0;
for TrigTest::sines() -> $angle
for @sines -> $angle
{
next if abs(sinh($angle.key())) < 1e-6;
my $desired-result = cosh($angle.key()) / sinh($angle.key());
Expand Down Expand Up @@ -97,7 +127,7 @@ is_approx(cotanh(:x((4.7123889804284).Str)), 1.000161412061, "cotanh(:x(Str)) -

# acotanh tests

for TrigTest::sines() -> $angle
for @sines -> $angle
{
next if abs(sinh($angle.key())) < 1e-6;
my $desired-result = cosh($angle.key()) / sinh($angle.key());
Expand Down

0 comments on commit 59b5e94

Please sign in to comment.