Debian Codegraph @

js/src/tests/non262/Math/15.8.2.7.js

raw
1 /* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
7 /**
8 File Name: 15.8.2.7.js
9 ECMA Section: 15.8.2.7 cos( x )
10 Description: return an approximation to the cosine of the
11 argument. argument is expressed in radians
12 Author: [email protected]
13 Date: 7 july 1997
14
15 */
16
17 var SECTION = "15.8.2.7";
18 var TITLE = "Math.cos(x)";
19
20 writeHeaderToLog( SECTION + " "+ TITLE);
21
22 new TestCase(
23 "Math.cos.length",
24 1,
25 Math.cos.length );
26
27 new TestCase(
28 "Math.cos()",
29 Number.NaN,
30 Math.cos() );
31
32 new TestCase(
33 "Math.cos(void 0)",
34 Number.NaN,
35 Math.cos(void 0) );
36
37 new TestCase(
38 "Math.cos(false)",
39 1,
40 Math.cos(false) );
41
42 new TestCase(
43 "Math.cos(null)",
44 1,
45 Math.cos(null) );
46
47 new TestCase(
48 "Math.cos('0')",
49 1,
50 Math.cos('0') );
51
52 new TestCase(
53 "Math.cos('Infinity')",
54 Number.NaN,
55 Math.cos("Infinity") );
56
57 new TestCase(
58 "Math.cos('3.14159265359')",
59 -1,
60 Math.cos('3.14159265359') );
61
62 new TestCase(
63 "Math.cos(NaN)",
64 Number.NaN,
65 Math.cos(Number.NaN) );
66
67 new TestCase(
68 "Math.cos(0)",
69 1,
70 Math.cos(0) );
71
72 new TestCase(
73 "Math.cos(-0)",
74 1,
75 Math.cos(-0) );
76
77 new TestCase(
78 "Math.cos(Infinity)",
79 Number.NaN,
80 Math.cos(Number.POSITIVE_INFINITY) );
81
82 new TestCase(
83 "Math.cos(-Infinity)",
84 Number.NaN,
85 Math.cos(Number.NEGATIVE_INFINITY) );
86
87 new TestCase(
88 "Math.cos(0.7853981633974)",
89 0.7071067811865,
90 Math.cos(0.7853981633974) );
91
92 new TestCase(
93 "Math.cos(1.570796326795)",
94 0,
95 Math.cos(1.570796326795) );
96
97 new TestCase(
98 "Math.cos(2.356194490192)",
99 -0.7071067811865,
100 Math.cos(2.356194490192) );
101
102 new TestCase(
103 "Math.cos(3.14159265359)",
104 -1,
105 Math.cos(3.14159265359) );
106
107 new TestCase(
108 "Math.cos(3.926990816987)",
109 -0.7071067811865,
110 Math.cos(3.926990816987) );
111
112 new TestCase(
113 "Math.cos(4.712388980385)",
114 0,
115 Math.cos(4.712388980385) );
116
117 new TestCase(
118 "Math.cos(5.497787143782)",
119 0.7071067811865,
120 Math.cos(5.497787143782) );
121
122 new TestCase(
123 "Math.cos(Math.PI*2)",
124 1,
125 Math.cos(Math.PI*2) );
126
127 new TestCase(
128 "Math.cos(Math.PI/4)",
129 Math.SQRT2/2,
130 Math.cos(Math.PI/4) );
131
132 new TestCase(
133 "Math.cos(Math.PI/2)",
134 0,
135 Math.cos(Math.PI/2) );
136
137 new TestCase(
138 "Math.cos(3*Math.PI/4)",
139 -Math.SQRT2/2,
140 Math.cos(3*Math.PI/4) );
141
142 new TestCase(
143 "Math.cos(Math.PI)",
144 -1,
145 Math.cos(Math.PI) );
146
147 new TestCase(
148 "Math.cos(5*Math.PI/4)",
149 -Math.SQRT2/2,
150 Math.cos(5*Math.PI/4) );
151
152 new TestCase(
153 "Math.cos(3*Math.PI/2)",
154 0,
155 Math.cos(3*Math.PI/2) );
156
157 new TestCase(
158 "Math.cos(7*Math.PI/4)",
159 Math.SQRT2/2,
160 Math.cos(7*Math.PI/4) );
161
162 new TestCase(
163 "Math.cos(Math.PI*2)",
164 1,
165 Math.cos(2*Math.PI) );
166
167 new TestCase(
168 "Math.cos(-0.7853981633974)",
169 0.7071067811865,
170 Math.cos(-0.7853981633974) );
171
172 new TestCase(
173 "Math.cos(-1.570796326795)",
174 0,
175 Math.cos(-1.570796326795) );
176
177 new TestCase(
178 "Math.cos(-2.3561944901920)",
179 -.7071067811865,
180 Math.cos(2.3561944901920) );
181
182 new TestCase(
183 "Math.cos(-3.14159265359)",
184 -1,
185 Math.cos(3.14159265359) );
186
187 new TestCase(
188 "Math.cos(-3.926990816987)",
189 -0.7071067811865,
190 Math.cos(3.926990816987) );
191
192 new TestCase(
193 "Math.cos(-4.712388980385)",
194 0,
195 Math.cos(4.712388980385) );
196
197 new TestCase(
198 "Math.cos(-5.497787143782)",
199 0.7071067811865,
200 Math.cos(5.497787143782) );
201
202 new TestCase(
203 "Math.cos(-6.28318530718)",
204 1,
205 Math.cos(6.28318530718) );
206
207 new TestCase(
208 "Math.cos(-Math.PI/4)",
209 Math.SQRT2/2,
210 Math.cos(-Math.PI/4) );
211
212 new TestCase(
213 "Math.cos(-Math.PI/2)",
214 0,
215 Math.cos(-Math.PI/2) );
216
217 new TestCase(
218 "Math.cos(-3*Math.PI/4)",
219 -Math.SQRT2/2,
220 Math.cos(-3*Math.PI/4) );
221
222 new TestCase(
223 "Math.cos(-Math.PI)",
224 -1,
225 Math.cos(-Math.PI) );
226
227 new TestCase(
228 "Math.cos(-5*Math.PI/4)",
229 -Math.SQRT2/2,
230 Math.cos(-5*Math.PI/4) );
231
232 new TestCase(
233 "Math.cos(-3*Math.PI/2)",
234 0,
235 Math.cos(-3*Math.PI/2) );
236
237 new TestCase(
238 "Math.cos(-7*Math.PI/4)",
239 Math.SQRT2/2,
240 Math.cos(-7*Math.PI/4) );
241
242 new TestCase(
243 "Math.cos(-Math.PI*2)",
244 1,
245 Math.cos(-Math.PI*2) );
246
247 test();