Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 196 lines (152 sloc) 5.942 kb
4277cf54 » colomon
2009-10-03 [t/spec] Full version of the new trig tests. (Still a bit of work to …
1 # WARNING:
2 # This is a generated file and should not be edited directly.
3 # look into generate-tests.pl instead
217fb45d » colomon
2010-07-14 [t/spec] Overhaul of the trig tests. generate-tests.pl still desperat…
4
4277cf54 » colomon
2009-10-03 [t/spec] Full version of the new trig tests. (Still a bit of work to …
5 use v6;
6 use Test;
59b5e94c » colomon
2011-07-26 Remove TrigTestSupport.pm.
7
8 sub degrees-to-radians($x) {
9 $x * (312689/99532) / 180;
10 }
11
12 my @sines = (
13 degrees-to-radians(-360) => 0,
14 degrees-to-radians(135 - 360) => 1/2*sqrt(2),
15 degrees-to-radians(330 - 360) => -0.5,
16 degrees-to-radians(0) => 0,
17 degrees-to-radians(30) => 0.5,
18 degrees-to-radians(45) => 1/2*sqrt(2),
19 degrees-to-radians(90) => 1,
20 degrees-to-radians(135) => 1/2*sqrt(2),
21 degrees-to-radians(180) => 0,
22 degrees-to-radians(225) => -1/2*sqrt(2),
23 degrees-to-radians(270) => -1,
24 degrees-to-radians(315) => -1/2*sqrt(2),
25 degrees-to-radians(360) => 0,
26 degrees-to-radians(30 + 360) => 0.5,
27 degrees-to-radians(225 + 360) => -1/2*sqrt(2),
28 degrees-to-radians(720) => 0
29 );
30
5ce04dc0 » colomon
2012-01-15 Add FatRat tests (appropriately fudged for Rakudo), remove fudging fo…
31 my @cosines = @sines.map({; $_.key - degrees-to-radians(90) => $_.value }); #OK
59b5e94c » colomon
2011-07-26 Remove TrigTestSupport.pm.
32
5ce04dc0 » colomon
2012-01-15 Add FatRat tests (appropriately fudged for Rakudo), remove fudging fo…
33 my @sinhes = @sines.grep({ $_.key < degrees-to-radians(500) }).map({; $_.key => #OK
59b5e94c » colomon
2011-07-26 Remove TrigTestSupport.pm.
34 (exp($_.key) - exp(-$_.key)) / 2.0 });
35
5ce04dc0 » colomon
2012-01-15 Add FatRat tests (appropriately fudged for Rakudo), remove fudging fo…
36 my @coshes = @sines.grep({ $_.key < degrees-to-radians(500) }).map({; $_.key => #OK
59b5e94c » colomon
2011-07-26 Remove TrigTestSupport.pm.
37 (exp($_.key) + exp(-$_.key)) / 2.0 });
38
3900295b » colomon
2011-07-26 Rearrange NotComplex and DifferentReal a bit.
39 class NotComplex is Cool {
40 has $.value;
41
42 multi method new(Complex $value is copy) {
43 self.bless(*, :$value);
44 }
45
46 multi method Numeric() {
47 self.value;
48 }
49 }
50
51 class DifferentReal is Real {
52 has $.value;
53
54 multi method new($value is copy) {
55 self.bless(*, :$value);
56 }
57
58 multi method Bridge() {
5ce04dc0 » colomon
2012-01-15 Add FatRat tests (appropriately fudged for Rakudo), remove fudging fo…
59 self.value.Num;
3900295b » colomon
2011-07-26 Rearrange NotComplex and DifferentReal a bit.
60 }
61 }
62
4277cf54 » colomon
2009-10-03 [t/spec] Full version of the new trig tests. (Still a bit of work to …
63
64
65 # cos tests
66
59b5e94c » colomon
2011-07-26 Remove TrigTestSupport.pm.
67 for @cosines -> $angle
4277cf54 » colomon
2009-10-03 [t/spec] Full version of the new trig tests. (Still a bit of work to …
68 {
69
aea78b84 » colomon
2011-07-26 Class AngleAndResult gone completely now.
70 my $desired-result = $angle.value;
4277cf54 » colomon
2009-10-03 [t/spec] Full version of the new trig tests. (Still a bit of work to …
71
217fb45d » colomon
2010-07-14 [t/spec] Overhaul of the trig tests. generate-tests.pl still desperat…
72 # Num.cos tests -- very thorough
aea78b84 » colomon
2011-07-26 Class AngleAndResult gone completely now.
73 is_approx($angle.key().cos, $desired-result,
74 "Num.cos - {$angle.key()}");
4277cf54 » colomon
2009-10-03 [t/spec] Full version of the new trig tests. (Still a bit of work to …
75
217fb45d » colomon
2010-07-14 [t/spec] Overhaul of the trig tests. generate-tests.pl still desperat…
76 # Complex.cos tests -- also very thorough
aea78b84 » colomon
2011-07-26 Class AngleAndResult gone completely now.
77 my Complex $zp0 = $angle.key + 0.0i;
217fb45d » colomon
2010-07-14 [t/spec] Overhaul of the trig tests. generate-tests.pl still desperat…
78 my Complex $sz0 = $desired-result + 0i;
aea78b84 » colomon
2011-07-26 Class AngleAndResult gone completely now.
79 my Complex $zp1 = $angle.key + 1.0i;
4277cf54 » colomon
2009-10-03 [t/spec] Full version of the new trig tests. (Still a bit of work to …
80 my Complex $sz1 = { (exp($_ * 1i) + exp(-$_ * 1i)) / 2 }($zp1);
aea78b84 » colomon
2011-07-26 Class AngleAndResult gone completely now.
81 my Complex $zp2 = $angle.key + 2.0i;
4277cf54 » colomon
2009-10-03 [t/spec] Full version of the new trig tests. (Still a bit of work to …
82 my Complex $sz2 = { (exp($_ * 1i) + exp(-$_ * 1i)) / 2 }($zp2);
83
079975f9 » colomon
2011-06-29 Remove the trigbase tests from the trig spectests.
84 is_approx($zp0.cos, $sz0, "Complex.cos - $zp0");
85 is_approx($zp1.cos, $sz1, "Complex.cos - $zp1");
86 is_approx($zp2.cos, $sz2, "Complex.cos - $zp2");
4277cf54 » colomon
2009-10-03 [t/spec] Full version of the new trig tests. (Still a bit of work to …
87 }
88
4661e6bc » colomon
2011-09-24 Update generated trig files with fudging for Niecza.
89
3d414e00 » colomon
2011-07-27 Get rid of some obsolete stuff involving bases.
90 {
91 is(cos(Inf), NaN, "cos(Inf) -");
92 is(cos(-Inf), NaN, "cos(-Inf) -");
93 }
4277cf54 » colomon
2009-10-03 [t/spec] Full version of the new trig tests. (Still a bit of work to …
94
3900295b » colomon
2011-07-26 Rearrange NotComplex and DifferentReal a bit.
95 {
96 # Num tests
97 is_approx(cos((-7.85398163404734).Num), 0, "cos(Num) - -7.85398163404734");
98 }
217fb45d » colomon
2010-07-14 [t/spec] Overhaul of the trig tests. generate-tests.pl still desperat…
99
3900295b » colomon
2011-07-26 Rearrange NotComplex and DifferentReal a bit.
100 {
101 # Rat tests
07f400b9 » moritz
2011-07-29 [trig] do not generate tests for named parameters; regen test files
102 is_approx((-5.49778714383314).Rat(1e-9).cos, 0.707106781186548, "Rat.cos - -5.49778714383314");
103 is_approx(cos((-2.09439510241262).Rat(1e-9)), -0.5, "cos(Rat) - -2.09439510241262");
3900295b » colomon
2011-07-26 Rearrange NotComplex and DifferentReal a bit.
104 }
217fb45d » colomon
2010-07-14 [t/spec] Overhaul of the trig tests. generate-tests.pl still desperat…
105
3900295b » colomon
2011-07-26 Rearrange NotComplex and DifferentReal a bit.
106 {
107 # Complex tests
07f400b9 » moritz
2011-07-29 [trig] do not generate tests for named parameters; regen test files
108 is_approx(cos((-1.57079632680947 + 2i).Complex), -5.48212707989036e-11 + 3.62686040784702i, "cos(Complex) - -1.57079632680947 + 2i");
3900295b » colomon
2011-07-26 Rearrange NotComplex and DifferentReal a bit.
109 }
217fb45d » colomon
2010-07-14 [t/spec] Overhaul of the trig tests. generate-tests.pl still desperat…
110
3900295b » colomon
2011-07-26 Rearrange NotComplex and DifferentReal a bit.
111 {
112 # Str tests
07f400b9 » moritz
2011-07-29 [trig] do not generate tests for named parameters; regen test files
113 is_approx((-1.04719755120631).Str.cos, 0.5, "Str.cos - -1.04719755120631");
114 is_approx(cos((-0.785398163404734).Str), 0.707106781186548, "cos(Str) - -0.785398163404734");
3900295b » colomon
2011-07-26 Rearrange NotComplex and DifferentReal a bit.
115 }
217fb45d » colomon
2010-07-14 [t/spec] Overhaul of the trig tests. generate-tests.pl still desperat…
116
d05d08a3 » colomon
2011-07-26 Move classes NotComplex and DifferentReal from TrigTestSupport.pm to …
117 {
118 # NotComplex tests
5ce04dc0 » colomon
2012-01-15 Add FatRat tests (appropriately fudged for Rakudo), remove fudging fo…
119 is_approx(NotComplex.new(0 + 2i).cos, 3.76219569108363 + 0i, "NotComplex.cos - 0 + 2i");
07f400b9 » moritz
2011-07-29 [trig] do not generate tests for named parameters; regen test files
120 is_approx(cos(NotComplex.new(0.785398163404734 + 2i)), 2.66027408529666 - 2.56457758882432i, "cos(NotComplex) - 0.785398163404734 + 2i");
d05d08a3 » colomon
2011-07-26 Move classes NotComplex and DifferentReal from TrigTestSupport.pm to …
121 }
122
123 {
124 # DifferentReal tests
07f400b9 » moritz
2011-07-29 [trig] do not generate tests for named parameters; regen test files
125 is_approx(DifferentReal.new(1.57079632680947).cos, 0, "DifferentReal.cos - 1.57079632680947");
126 is_approx(cos(DifferentReal.new(2.3561944902142)), -0.707106781186548, "cos(DifferentReal) - 2.3561944902142");
d05d08a3 » colomon
2011-07-26 Move classes NotComplex and DifferentReal from TrigTestSupport.pm to …
127 }
079975f9 » colomon
2011-06-29 Remove the trigbase tests from the trig spectests.
128
5ce04dc0 » colomon
2012-01-15 Add FatRat tests (appropriately fudged for Rakudo), remove fudging fo…
129 {
130 # FatRat tests
131 is_approx((3.14159265361894).FatRat.cos, -1, "FatRat.cos - 3.14159265361894");
132 is_approx(cos((3.92699081702367).FatRat), -0.707106781186548, "cos(FatRat) - 3.92699081702367");
133 }
134
4277cf54 » colomon
2009-10-03 [t/spec] Full version of the new trig tests. (Still a bit of work to …
135
136 # acos tests
137
59b5e94c » colomon
2011-07-26 Remove TrigTestSupport.pm.
138 for @cosines -> $angle
4277cf54 » colomon
2009-10-03 [t/spec] Full version of the new trig tests. (Still a bit of work to …
139 {
140
aea78b84 » colomon
2011-07-26 Class AngleAndResult gone completely now.
141 my $desired-result = $angle.value;
217fb45d » colomon
2010-07-14 [t/spec] Overhaul of the trig tests. generate-tests.pl still desperat…
142
143 # Num.acos tests -- thorough
144 is_approx($desired-result.Num.acos.cos, $desired-result,
aea78b84 » colomon
2011-07-26 Class AngleAndResult gone completely now.
145 "Num.acos - {$angle.key()}");
4277cf54 » colomon
2009-10-03 [t/spec] Full version of the new trig tests. (Still a bit of work to …
146
217fb45d » colomon
2010-07-14 [t/spec] Overhaul of the trig tests. generate-tests.pl still desperat…
147 # Num.acos(Complex) tests -- thorough
148 for ($desired-result + 0i, $desired-result + .5i, $desired-result + 2i) -> $z {
4277cf54 » colomon
2009-10-03 [t/spec] Full version of the new trig tests. (Still a bit of work to …
149 is_approx($z.acos.cos, $z,
5c6b8e3f » colomon
2011-08-08 Actual trig tests generated by running the "Remove unneeded inverse s…
150 "Complex.acos - $z");
4277cf54 » colomon
2009-10-03 [t/spec] Full version of the new trig tests. (Still a bit of work to …
151 }
152 }
153
0c917fb9 » colomon
2011-07-27 Slightly better formatting.
154 {
155 # Num tests
156 is_approx(acos((0.707106781186548).Num), 0.785398163404734, "acos(Num) - 0.785398163404734");
157 }
158
159 {
160 # Rat tests
161 is_approx(((0.707106781186548).Rat(1e-9)).acos, 0.785398163404734, "Rat.acos - 0.785398163404734");
162 is_approx(acos((0.707106781186548).Rat(1e-9)), 0.785398163404734, "acos(Rat) - 0.785398163404734");
163 }
164
165 {
166 # Complex tests
5ce04dc0 » colomon
2012-01-15 Add FatRat tests (appropriately fudged for Rakudo), remove fudging fo…
167 is_approx(acos((0.785398163404734 + 2i).Complex), 1.22945740674052 - 1.49709293866352i, "acos(Complex) - 1.22945740674052 - 1.49709293866352i");
0c917fb9 » colomon
2011-07-27 Slightly better formatting.
168 }
169
170 {
171 # Str tests
172 is_approx(((0.707106781186548).Str).acos, 0.785398163404734, "Str.acos - 0.785398163404734");
173 is_approx(acos((0.707106781186548).Str), 0.785398163404734, "acos(Str) - 0.785398163404734");
174 }
175
176 {
177 # NotComplex tests
5ce04dc0 » colomon
2012-01-15 Add FatRat tests (appropriately fudged for Rakudo), remove fudging fo…
178 is_approx((NotComplex.new(0.785398163404734 + 2i)).acos, 1.22945740674052 - 1.49709293866352i, "NotComplex.acos - 1.22945740674052 - 1.49709293866352i");
179 is_approx(acos(NotComplex.new(0.785398163404734 + 2i)), 1.22945740674052 - 1.49709293866352i, "acos(NotComplex) - 1.22945740674052 - 1.49709293866352i");
0c917fb9 » colomon
2011-07-27 Slightly better formatting.
180 }
181
182 {
183 # DifferentReal tests
184 is_approx((DifferentReal.new(0.707106781186548)).acos, 0.785398163404734, "DifferentReal.acos - 0.785398163404734");
185 is_approx(acos(DifferentReal.new(0.707106781186548)), 0.785398163404734, "acos(DifferentReal) - 0.785398163404734");
186 }
217fb45d » colomon
2010-07-14 [t/spec] Overhaul of the trig tests. generate-tests.pl still desperat…
187
5ce04dc0 » colomon
2012-01-15 Add FatRat tests (appropriately fudged for Rakudo), remove fudging fo…
188 {
189 # FatRat tests
190 is_approx(((0.707106781186548).FatRat).acos, 0.785398163404734, "FatRat.acos - 0.785398163404734");
191 is_approx(acos((0.707106781186548).FatRat), 0.785398163404734, "acos(FatRat) - 0.785398163404734");
192 }
193
e76dd4c7 » moritz
2010-12-31 s/done_testing/done/ as per recent S24 changes
194 done;
4277cf54 » colomon
2009-10-03 [t/spec] Full version of the new trig tests. (Still a bit of work to …
195
196 # vim: ft=perl6 nomodifiable
Something went wrong with that request. Please try again.