Skip to content

Commit

Permalink
[t/spec] Overhaul of the trig tests. generate-tests.pl still desperat…
Browse files Browse the repository at this point in the history
…ely needs some refactoring, but the generated

tests are now shorter and more thorough than they were previously.


git-svn-id: http://svn.pugscode.org/pugs@31683 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information
colomon committed Jul 14, 2010
1 parent c79824b commit 217fb45
Show file tree
Hide file tree
Showing 17 changed files with 2,192 additions and 3,061 deletions.
6 changes: 5 additions & 1 deletion S32-trig/TrigTestSupport
Expand Up @@ -14,7 +14,11 @@ class AngleAndResult
multi method new(Int $angle_in_degrees is copy, $result is copy) {
self.bless(*, :$angle_in_degrees, :$result);
}


multi method perl() {
"AngleAndResult.new($.angle_in_degrees, $.result)";
}

method complex($imaginary_part_in_radians, $base) {
my $z_in_radians = $.angle_in_degrees / 180.0 * pi + ($imaginary_part_in_radians)i;
$z_in_radians * @radians-to-whatever[$base];
Expand Down
468 changes: 293 additions & 175 deletions S32-trig/atan2.t

Large diffs are not rendered by default.

339 changes: 131 additions & 208 deletions S32-trig/cos.t

Large diffs are not rendered by default.

341 changes: 132 additions & 209 deletions S32-trig/cosec.t

Large diffs are not rendered by default.

341 changes: 132 additions & 209 deletions S32-trig/cosech.t

Large diffs are not rendered by default.

339 changes: 131 additions & 208 deletions S32-trig/cosh.t

Large diffs are not rendered by default.

341 changes: 132 additions & 209 deletions S32-trig/cotan.t

Large diffs are not rendered by default.

341 changes: 132 additions & 209 deletions S32-trig/cotanh.t

Large diffs are not rendered by default.

613 changes: 277 additions & 336 deletions S32-trig/generate-tests.pl

Large diffs are not rendered by default.

341 changes: 132 additions & 209 deletions S32-trig/sec.t

Large diffs are not rendered by default.

341 changes: 132 additions & 209 deletions S32-trig/sech.t

Large diffs are not rendered by default.

339 changes: 131 additions & 208 deletions S32-trig/sin.t

Large diffs are not rendered by default.

339 changes: 131 additions & 208 deletions S32-trig/sinh.t

Large diffs are not rendered by default.

341 changes: 132 additions & 209 deletions S32-trig/tan.t

Large diffs are not rendered by default.

341 changes: 132 additions & 209 deletions S32-trig/tanh.t

Large diffs are not rendered by default.

76 changes: 32 additions & 44 deletions S32-trig/trig_functions
@@ -1,73 +1,65 @@
# Simple file to control trig test creation.

Function: sin
loop_over: @sines
setup:
my $desired_result = $angle.result;
loop_over: TrigTest::sines()
desired_result: $angle.result
end-setup
complex_check: { (exp($_ * 1i) - exp(-$_ * 1i)) / 2i }
End

Function: cos
loop_over: @cosines
setup:
my $desired_result = $angle.result;
loop_over: TrigTest::cosines()
desired_result: $angle.result
end-setup
complex_check: { (exp($_ * 1i) + exp(-$_ * 1i)) / 2 }
End

Function: tan
loop_over: @sines
setup:
next if abs(cos($angle.num('radians'))) < 1e-6;
my $desired_result = sin($angle.num('radians')) / cos($angle.num('radians'));
loop_over: TrigTest::sines()
skip: abs(cos($angle)) < 1e-6
desired_result: sin($angle.num(Radians)) / cos($angle.num(Radians))
end-setup
complex_check: { sin($_) / cos($_) }
End

Function: sec
loop_over: @cosines
setup:
next if abs(cos($angle.num('radians'))) < 1e-6;
my $desired_result = 1.0 / cos($angle.num('radians'));
loop_over: TrigTest::cosines()
skip: abs(cos($angle)) < 1e-6
desired_result: 1.0 / cos($angle.num(Radians))
end-setup
rational_inverse_tests: (-3/2, -2/2, 2/2, 3/2)
complex_check: { 1.0 / cos($_) }
End

Function: cosec
loop_over: @sines
setup:
next if abs(sin($angle.num('radians'))) < 1e-6;
my $desired_result = 1.0 / sin($angle.num('radians'));
loop_over: TrigTest::sines()
skip: abs(sin($angle)) < 1e-6
desired_result: 1.0 / sin($angle.num(Radians))
end-setup
rational_inverse_tests: (-3/2, -2/2, 2/2, 3/2)
complex_check: { 1.0 / sin($_) }
End

Function: cotan
loop_over: @sines
setup:
next if abs(sin($angle.num('radians'))) < 1e-6;
my $desired_result = cos($angle.num('radians')) / sin($angle.num('radians'));
loop_over: TrigTest::sines()
skip: abs(sin($angle)) < 1e-6
desired_result: cos($angle.num(Radians)) / sin($angle.num(Radians))
end-setup
complex_check: { cos($_) / sin($_) }
End

Function: sinh
loop_over: @sinhes
setup:
my $desired_result = $angle.result;
loop_over: TrigTest::sinhes()
desired_result: $angle.result
end-setup
complex_check: { (exp($_) - exp(-$_)) / 2 }
plus_inf: Inf
minus_inf: -Inf
End

Function: cosh
loop_over: @coshes
setup:
my $desired_result = $angle.result;
loop_over: TrigTest::coshes()
desired_result: $angle.result
end-setup
rational_inverse_tests: (2/2, 3/2, 4/2, 5/2)
complex_check: { (exp($_) + exp(-$_)) / 2 }
Expand All @@ -76,10 +68,9 @@ minus_inf: Inf
End

Function: tanh
loop_over: @sines
setup:
next if abs(cosh($angle.num('radians'))) < 1e-6;
my $desired_result = sinh($angle.num('radians')) / cosh($angle.num('radians'));
loop_over: TrigTest::sines()
skip: abs(cosh($angle)) < 1e-6
desired_result: sinh($angle.num(Radians)) / cosh($angle.num(Radians))
end-setup
rational_inverse_tests: (-2/2, -1/2, 0/1, 1/2)
complex_check: { sinh($_) / cosh($_) }
Expand All @@ -88,10 +79,9 @@ minus_inf: -1
End

Function: sech
loop_over: @cosines
setup:
next if abs(cosh($angle.num('radians'))) < 1e-6;
my $desired_result = 1.0 / cosh($angle.num('radians'));
loop_over: TrigTest::cosines()
skip: abs(cosh($angle)) < 1e-6
desired_result: 1.0 / cosh($angle.num(Radians))
end-setup
rational_inverse_tests: (1/4, 1/2, 3/4, 2/2)
complex_check: { 1.0 / cosh($_) }
Expand All @@ -100,21 +90,19 @@ minus_inf: 0
End

Function: cosech
loop_over: @sines
setup:
next if abs(sinh($angle.num('radians'))) < 1e-6;
my $desired_result = 1.0 / sinh($angle.num('radians'));
loop_over: TrigTest::sines()
skip: abs(sinh($angle)) < 1e-6
desired_result: 1.0 / sinh($angle.num(Radians))
end-setup
complex_check: { 1.0 / sinh($_) }
plus_inf: 0
minus_inf: "-0"
End

Function: cotanh
loop_over: @sines
setup:
next if abs(sinh($angle.num('radians'))) < 1e-6;
my $desired_result = cosh($angle.num('radians')) / sinh($angle.num('radians'));
loop_over: TrigTest::sines()
skip: abs(sinh($angle)) < 1e-6
desired_result: cosh($angle.num(Radians)) / sinh($angle.num(Radians))
end-setup
rational_inverse_tests: (-4/2, -3/2, 3/2, 4/2)
complex_check: { cosh($_) / sinh ($_) }
Expand Down
6 changes: 5 additions & 1 deletion packages/TrigTestSupport.pm
Expand Up @@ -12,7 +12,11 @@ class AngleAndResult
multi method new(Int $angle_in_degrees is copy, $result is copy) {
self.bless(*, :$angle_in_degrees, :$result);
}


multi method perl() {
"AngleAndResult.new($.angle_in_degrees, $.result)";
}

method complex($imaginary_part_in_radians, $base) {
my $z_in_radians = $.angle_in_degrees / 180.0 * pi + ($imaginary_part_in_radians)i;
$z_in_radians * @radians-to-whatever[$base];
Expand Down

0 comments on commit 217fb45

Please sign in to comment.