Permalink
Browse files

[t/spec] Overhaul of the trig tests. generate-tests.pl still desperat…

…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...
1 parent c79824b commit 217fb45d6df881e6c38ab1cb2f2c593392fea51a colomon committed Jul 14, 2010
Showing with 2,192 additions and 3,061 deletions.
  1. +5 −1 S32-trig/TrigTestSupport
  2. +293 −175 S32-trig/atan2.t
  3. +131 −208 S32-trig/cos.t
  4. +132 −209 S32-trig/cosec.t
  5. +132 −209 S32-trig/cosech.t
  6. +131 −208 S32-trig/cosh.t
  7. +132 −209 S32-trig/cotan.t
  8. +132 −209 S32-trig/cotanh.t
  9. +277 −336 S32-trig/generate-tests.pl
  10. +132 −209 S32-trig/sec.t
  11. +132 −209 S32-trig/sech.t
  12. +131 −208 S32-trig/sin.t
  13. +131 −208 S32-trig/sinh.t
  14. +132 −209 S32-trig/tan.t
  15. +132 −209 S32-trig/tanh.t
  16. +32 −44 S32-trig/trig_functions
  17. +5 −1 packages/TrigTestSupport.pm
@@ -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];
View
Oops, something went wrong.
View
Oops, something went wrong.
View
Oops, something went wrong.
View
Oops, something went wrong.
View
Oops, something went wrong.
View
Oops, something went wrong.
View
Oops, something went wrong.
Oops, something went wrong.
View
Oops, something went wrong.
View
Oops, something went wrong.
View
Oops, something went wrong.
View
Oops, something went wrong.
View
Oops, something went wrong.
View
Oops, something went wrong.
@@ -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 }
@@ -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($_) }
@@ -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($_) }
@@ -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 ($_) }
@@ -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];

0 comments on commit 217fb45

Please sign in to comment.