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