Debian Codegraph @

rhino/testsrc/tests/ecma/Math/15.8.2.13.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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 gTestfile = '15.8.2.13.js';
7
8 /**
9 File Name: 15.8.2.13.js
10 ECMA Section: 15.8.2.13 Math.pow(x, y)
11 Description: return an approximation to the result of x
12 to the power of y. there are many special cases;
13 refer to the spec.
14 Author: [email protected]
15 Date: 9 july 1997
16 */
17
18 var SECTION = "15.8.2.13";
19 var VERSION = "ECMA_1";
20 var TITLE = "Math.pow(x, y)";
21 var BUGNUMBER="77141";
22
23 startTest();
24
25 writeHeaderToLog( SECTION + " "+ TITLE);
26
27 new TestCase( SECTION,
28 "Math.pow.length",
29 2,
30 Math.pow.length );
31
32 new TestCase( SECTION,
33 "Math.pow()",
34 Number.NaN,
35 Math.pow() );
36
37 new TestCase( SECTION,
38 "Math.pow(null, null)",
39 1,
40 Math.pow(null,null) );
41
42 new TestCase( SECTION,
43 "Math.pow(void 0, void 0)",
44 Number.NaN,
45 Math.pow(void 0, void 0));
46
47 new TestCase( SECTION,
48 "Math.pow(true, false)",
49 1,
50 Math.pow(true, false) );
51
52 new TestCase( SECTION,
53 "Math.pow(false,true)",
54 0,
55 Math.pow(false,true) );
56
57 new TestCase( SECTION,
58 "Math.pow('2','32')",
59 4294967296,
60 Math.pow('2','32') );
61
62 new TestCase( SECTION,
63 "Math.pow(1,NaN)",
64 Number.NaN,
65 Math.pow(1,Number.NaN) );
66
67 new TestCase( SECTION,
68 "Math.pow(0,NaN)",
69 Number.NaN,
70 Math.pow(0,Number.NaN) );
71
72 new TestCase( SECTION,
73 "Math.pow(NaN,0)",
74 1,
75 Math.pow(Number.NaN,0) );
76
77 new TestCase( SECTION,
78 "Math.pow(NaN,-0)",
79 1,
80 Math.pow(Number.NaN,-0) );
81
82 new TestCase( SECTION,
83 "Math.pow(NaN,1)",
84 Number.NaN,
85 Math.pow(Number.NaN, 1) );
86
87 new TestCase( SECTION,
88 "Math.pow(NaN,.5)",
89 Number.NaN,
90 Math.pow(Number.NaN, .5) );
91
92 new TestCase( SECTION,
93 "Math.pow(1.00000001, Infinity)",
94 Number.POSITIVE_INFINITY,
95 Math.pow(1.00000001, Number.POSITIVE_INFINITY) );
96
97 new TestCase( SECTION,
98 "Math.pow(1.00000001, -Infinity)",
99 0,
100 Math.pow(1.00000001, Number.NEGATIVE_INFINITY) );
101
102 new TestCase( SECTION,
103 "Math.pow(-1.00000001, Infinity)",
104 Number.POSITIVE_INFINITY,
105 Math.pow(-1.00000001,Number.POSITIVE_INFINITY) );
106
107 new TestCase( SECTION,
108 "Math.pow(-1.00000001, -Infinity)",
109 0,
110 Math.pow(-1.00000001,Number.NEGATIVE_INFINITY) );
111
112 new TestCase( SECTION,
113 "Math.pow(1, Infinity)",
114 Number.NaN,
115 Math.pow(1, Number.POSITIVE_INFINITY) );
116
117 new TestCase( SECTION,
118 "Math.pow(1, -Infinity)",
119 Number.NaN,
120 Math.pow(1, Number.NEGATIVE_INFINITY) );
121
122 new TestCase( SECTION,
123 "Math.pow(-1, Infinity)",
124 Number.NaN,
125 Math.pow(-1, Number.POSITIVE_INFINITY) );
126
127 new TestCase( SECTION,
128 "Math.pow(-1, -Infinity)",
129 Number.NaN,
130 Math.pow(-1, Number.NEGATIVE_INFINITY) );
131
132 new TestCase( SECTION,
133 "Math.pow(.0000000009, Infinity)",
134 0,
135 Math.pow(.0000000009, Number.POSITIVE_INFINITY) );
136
137 new TestCase( SECTION,
138 "Math.pow(-.0000000009, Infinity)",
139 0,
140 Math.pow(-.0000000009, Number.POSITIVE_INFINITY) );
141
142 new TestCase( SECTION,
143 "Math.pow(.0000000009, -Infinity)",
144 Number.POSITIVE_INFINITY,
145 Math.pow(-.0000000009, Number.NEGATIVE_INFINITY) );
146
147 new TestCase( SECTION,
148 "Math.pow(Infinity, .00000000001)",
149 Number.POSITIVE_INFINITY,
150 Math.pow(Number.POSITIVE_INFINITY,.00000000001) );
151
152 new TestCase( SECTION,
153 "Math.pow(Infinity, 1)",
154 Number.POSITIVE_INFINITY,
155 Math.pow(Number.POSITIVE_INFINITY, 1) );
156
157 new TestCase( SECTION,
158 "Math.pow(Infinity, -.00000000001)",
159 0,
160 Math.pow(Number.POSITIVE_INFINITY, -.00000000001) );
161
162 new TestCase( SECTION,
163 "Math.pow(Infinity, -1)",
164 0,
165 Math.pow(Number.POSITIVE_INFINITY, -1) );
166
167 new TestCase( SECTION,
168 "Math.pow(-Infinity, 1)",
169 Number.NEGATIVE_INFINITY,
170 Math.pow(Number.NEGATIVE_INFINITY, 1) );
171
172 new TestCase( SECTION,
173 "Math.pow(-Infinity, 333)",
174 Number.NEGATIVE_INFINITY,
175 Math.pow(Number.NEGATIVE_INFINITY, 333) );
176
177 new TestCase( SECTION,
178 "Math.pow(Infinity, 2)",
179 Number.POSITIVE_INFINITY,
180 Math.pow(Number.POSITIVE_INFINITY, 2) );
181
182 new TestCase( SECTION,
183 "Math.pow(-Infinity, 666)",
184 Number.POSITIVE_INFINITY,
185 Math.pow(Number.NEGATIVE_INFINITY, 666) );
186
187 new TestCase( SECTION,
188 "Math.pow(-Infinity, 0.5)",
189 Number.POSITIVE_INFINITY,
190 Math.pow(Number.NEGATIVE_INFINITY, 0.5) );
191
192 new TestCase( SECTION,
193 "Math.pow(-Infinity, Infinity)",
194 Number.POSITIVE_INFINITY,
195 Math.pow(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) );
196
197 new TestCase( SECTION,
198 "Math.pow(-Infinity, -1)",
199 -0,
200 Math.pow(Number.NEGATIVE_INFINITY, -1) );
201
202 new TestCase( SECTION,
203 "Infinity/Math.pow(-Infinity, -1)",
204 -Infinity,
205 Infinity/Math.pow(Number.NEGATIVE_INFINITY, -1) );
206
207 new TestCase( SECTION,
208 "Math.pow(-Infinity, -3)",
209 -0,
210 Math.pow(Number.NEGATIVE_INFINITY, -3) );
211
212 new TestCase( SECTION,
213 "Math.pow(-Infinity, -2)",
214 0,
215 Math.pow(Number.NEGATIVE_INFINITY, -2) );
216
217 new TestCase( SECTION,
218 "Math.pow(-Infinity, -0.5)",
219 0,
220 Math.pow(Number.NEGATIVE_INFINITY,-0.5) );
221
222 new TestCase( SECTION,
223 "Math.pow(-Infinity, -Infinity)",
224 0,
225 Math.pow(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) );
226
227 new TestCase( SECTION,
228 "Math.pow(0, 1)",
229 0,
230 Math.pow(0,1) );
231
232 new TestCase( SECTION,
233 "Math.pow(0, 0)",
234 1,
235 Math.pow(0,0) );
236
237 new TestCase( SECTION,
238 "Math.pow(1, 0)",
239 1,
240 Math.pow(1,0) );
241
242 new TestCase( SECTION,
243 "Math.pow(-1, 0)",
244 1,
245 Math.pow(-1,0) );
246
247 new TestCase( SECTION,
248 "Math.pow(0, 0.5)",
249 0,
250 Math.pow(0,0.5) );
251
252 new TestCase( SECTION,
253 "Math.pow(0, 1000)",
254 0,
255 Math.pow(0,1000) );
256
257 new TestCase( SECTION,
258 "Math.pow(0, Infinity)",
259 0,
260 Math.pow(0, Number.POSITIVE_INFINITY) );
261
262 new TestCase( SECTION,
263 "Math.pow(0, -1)",
264 Number.POSITIVE_INFINITY,
265 Math.pow(0, -1) );
266
267 new TestCase( SECTION,
268 "Math.pow(0, -0.5)",
269 Number.POSITIVE_INFINITY,
270 Math.pow(0, -0.5) );
271
272 new TestCase( SECTION,
273 "Math.pow(0, -1000)",
274 Number.POSITIVE_INFINITY,
275 Math.pow(0, -1000) );
276
277 new TestCase( SECTION,
278 "Math.pow(0, -Infinity)",
279 Number.POSITIVE_INFINITY,
280 Math.pow(0, Number.NEGATIVE_INFINITY) );
281
282 new TestCase( SECTION,
283 "Math.pow(-0, 1)",
284 -0,
285 Math.pow(-0, 1) );
286
287 new TestCase( SECTION,
288 "Math.pow(-0, 3)",
289 -0,
290 Math.pow(-0,3) );
291
292 new TestCase( SECTION,
293 "Infinity/Math.pow(-0, 1)",
294 -Infinity,
295 Infinity/Math.pow(-0, 1) );
296
297 new TestCase( SECTION,
298 "Infinity/Math.pow(-0, 3)",
299 -Infinity,
300 Infinity/Math.pow(-0,3) );
301
302 new TestCase( SECTION,
303 "Math.pow(-0, 2)",
304 0,
305 Math.pow(-0,2) );
306
307 new TestCase( SECTION,
308 "Math.pow(-0, Infinity)",
309 0,
310 Math.pow(-0, Number.POSITIVE_INFINITY) );
311
312 new TestCase( SECTION,
313 "Math.pow(-0, -1)",
314 Number.NEGATIVE_INFINITY,
315 Math.pow(-0, -1) );
316
317 new TestCase( SECTION,
318 "Math.pow(-0, -10001)",
319 Number.NEGATIVE_INFINITY,
320 Math.pow(-0, -10001) );
321
322 new TestCase( SECTION,
323 "Math.pow(-0, -2)",
324 Number.POSITIVE_INFINITY,
325 Math.pow(-0, -2) );
326
327 new TestCase( SECTION,
328 "Math.pow(-0, 0.5)",
329 0,
330 Math.pow(-0, 0.5) );
331
332 new TestCase( SECTION,
333 "Math.pow(-0, Infinity)",
334 0,
335 Math.pow(-0, Number.POSITIVE_INFINITY) );
336
337 new TestCase( SECTION,
338 "Math.pow(-1, 0.5)",
339 Number.NaN,
340 Math.pow(-1, 0.5) );
341
342 new TestCase( SECTION,
343 "Math.pow(-1, NaN)",
344 Number.NaN,
345 Math.pow(-1, Number.NaN) );
346
347 new TestCase( SECTION,
348 "Math.pow(-1, -0.5)",
349 Number.NaN,
350 Math.pow(-1, -0.5) );
351
352 test();