1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is Mozilla Communicator client code, released
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
41 File Name: 15.8.2.13.js
42 ECMA Section: 15.8.2.13 Math.pow(x, y)
43 Description: return an approximation to the result of x
44 to the power of y. there are many special cases;
46 Author: christine@netscape.com
50 var SECTION = "15.8.2.13";
51 var VERSION = "ECMA_1";
52 var TITLE = "Math.pow(x, y)";
53 var BUGNUMBER="77141";
57 writeHeaderToLog( SECTION + " "+ TITLE);
59 new TestCase( SECTION,
64 new TestCase( SECTION,
69 new TestCase( SECTION,
70 "Math.pow(null, null)",
72 Math.pow(null,null) );
74 new TestCase( SECTION,
75 "Math.pow(void 0, void 0)",
77 Math.pow(void 0, void 0));
79 new TestCase( SECTION,
80 "Math.pow(true, false)",
82 Math.pow(true, false) );
84 new TestCase( SECTION,
85 "Math.pow(false,true)",
87 Math.pow(false,true) );
89 new TestCase( SECTION,
94 new TestCase( SECTION,
97 Math.pow(1,Number.NaN) );
99 new TestCase( SECTION,
102 Math.pow(0,Number.NaN) );
104 new TestCase( SECTION,
107 Math.pow(Number.NaN,0) );
109 new TestCase( SECTION,
112 Math.pow(Number.NaN,-0) );
114 new TestCase( SECTION,
117 Math.pow(Number.NaN, 1) );
119 new TestCase( SECTION,
122 Math.pow(Number.NaN, .5) );
124 new TestCase( SECTION,
125 "Math.pow(1.00000001, Infinity)",
126 Number.POSITIVE_INFINITY,
127 Math.pow(1.00000001, Number.POSITIVE_INFINITY) );
129 new TestCase( SECTION,
130 "Math.pow(1.00000001, -Infinity)",
132 Math.pow(1.00000001, Number.NEGATIVE_INFINITY) );
134 new TestCase( SECTION,
135 "Math.pow(-1.00000001, Infinity)",
136 Number.POSITIVE_INFINITY,
137 Math.pow(-1.00000001,Number.POSITIVE_INFINITY) );
139 new TestCase( SECTION,
140 "Math.pow(-1.00000001, -Infinity)",
142 Math.pow(-1.00000001,Number.NEGATIVE_INFINITY) );
144 new TestCase( SECTION,
145 "Math.pow(1, Infinity)",
147 Math.pow(1, Number.POSITIVE_INFINITY) );
149 new TestCase( SECTION,
150 "Math.pow(1, -Infinity)",
152 Math.pow(1, Number.NEGATIVE_INFINITY) );
154 new TestCase( SECTION,
155 "Math.pow(-1, Infinity)",
157 Math.pow(-1, Number.POSITIVE_INFINITY) );
159 new TestCase( SECTION,
160 "Math.pow(-1, -Infinity)",
162 Math.pow(-1, Number.NEGATIVE_INFINITY) );
164 new TestCase( SECTION,
165 "Math.pow(.0000000009, Infinity)",
167 Math.pow(.0000000009, Number.POSITIVE_INFINITY) );
169 new TestCase( SECTION,
170 "Math.pow(-.0000000009, Infinity)",
172 Math.pow(-.0000000009, Number.POSITIVE_INFINITY) );
174 new TestCase( SECTION,
175 "Math.pow(.0000000009, -Infinity)",
176 Number.POSITIVE_INFINITY,
177 Math.pow(-.0000000009, Number.NEGATIVE_INFINITY) );
179 new TestCase( SECTION,
180 "Math.pow(Infinity, .00000000001)",
181 Number.POSITIVE_INFINITY,
182 Math.pow(Number.POSITIVE_INFINITY,.00000000001) );
184 new TestCase( SECTION,
185 "Math.pow(Infinity, 1)",
186 Number.POSITIVE_INFINITY,
187 Math.pow(Number.POSITIVE_INFINITY, 1) );
189 new TestCase( SECTION,
190 "Math.pow(Infinity, -.00000000001)",
192 Math.pow(Number.POSITIVE_INFINITY, -.00000000001) );
194 new TestCase( SECTION,
195 "Math.pow(Infinity, -1)",
197 Math.pow(Number.POSITIVE_INFINITY, -1) );
199 new TestCase( SECTION,
200 "Math.pow(-Infinity, 1)",
201 Number.NEGATIVE_INFINITY,
202 Math.pow(Number.NEGATIVE_INFINITY, 1) );
204 new TestCase( SECTION,
205 "Math.pow(-Infinity, 333)",
206 Number.NEGATIVE_INFINITY,
207 Math.pow(Number.NEGATIVE_INFINITY, 333) );
209 new TestCase( SECTION,
210 "Math.pow(Infinity, 2)",
211 Number.POSITIVE_INFINITY,
212 Math.pow(Number.POSITIVE_INFINITY, 2) );
214 new TestCase( SECTION,
215 "Math.pow(-Infinity, 666)",
216 Number.POSITIVE_INFINITY,
217 Math.pow(Number.NEGATIVE_INFINITY, 666) );
219 new TestCase( SECTION,
220 "Math.pow(-Infinity, 0.5)",
221 Number.POSITIVE_INFINITY,
222 Math.pow(Number.NEGATIVE_INFINITY, 0.5) );
224 new TestCase( SECTION,
225 "Math.pow(-Infinity, Infinity)",
226 Number.POSITIVE_INFINITY,
227 Math.pow(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) );
229 new TestCase( SECTION,
230 "Math.pow(-Infinity, -1)",
232 Math.pow(Number.NEGATIVE_INFINITY, -1) );
234 new TestCase( SECTION,
235 "Infinity/Math.pow(-Infinity, -1)",
237 Infinity/Math.pow(Number.NEGATIVE_INFINITY, -1) );
239 new TestCase( SECTION,
240 "Math.pow(-Infinity, -3)",
242 Math.pow(Number.NEGATIVE_INFINITY, -3) );
244 new TestCase( SECTION,
245 "Math.pow(-Infinity, -2)",
247 Math.pow(Number.NEGATIVE_INFINITY, -2) );
249 new TestCase( SECTION,
250 "Math.pow(-Infinity, -0.5)",
252 Math.pow(Number.NEGATIVE_INFINITY,-0.5) );
254 new TestCase( SECTION,
255 "Math.pow(-Infinity, -Infinity)",
257 Math.pow(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) );
259 new TestCase( SECTION,
264 new TestCase( SECTION,
269 new TestCase( SECTION,
274 new TestCase( SECTION,
279 new TestCase( SECTION,
284 new TestCase( SECTION,
289 new TestCase( SECTION,
290 "Math.pow(0, Infinity)",
292 Math.pow(0, Number.POSITIVE_INFINITY) );
294 new TestCase( SECTION,
296 Number.POSITIVE_INFINITY,
299 new TestCase( SECTION,
301 Number.POSITIVE_INFINITY,
304 new TestCase( SECTION,
305 "Math.pow(0, -1000)",
306 Number.POSITIVE_INFINITY,
307 Math.pow(0, -1000) );
309 new TestCase( SECTION,
310 "Math.pow(0, -Infinity)",
311 Number.POSITIVE_INFINITY,
312 Math.pow(0, Number.NEGATIVE_INFINITY) );
314 new TestCase( SECTION,
319 new TestCase( SECTION,
324 new TestCase( SECTION,
325 "Infinity/Math.pow(-0, 1)",
327 Infinity/Math.pow(-0, 1) );
329 new TestCase( SECTION,
330 "Infinity/Math.pow(-0, 3)",
332 Infinity/Math.pow(-0,3) );
334 new TestCase( SECTION,
339 new TestCase( SECTION,
340 "Math.pow(-0, Infinity)",
342 Math.pow(-0, Number.POSITIVE_INFINITY) );
344 new TestCase( SECTION,
346 Number.NEGATIVE_INFINITY,
349 new TestCase( SECTION,
350 "Math.pow(-0, -10001)",
351 Number.NEGATIVE_INFINITY,
352 Math.pow(-0, -10001) );
354 new TestCase( SECTION,
356 Number.POSITIVE_INFINITY,
359 new TestCase( SECTION,
364 new TestCase( SECTION,
365 "Math.pow(-0, Infinity)",
367 Math.pow(-0, Number.POSITIVE_INFINITY) );
369 new TestCase( SECTION,
374 new TestCase( SECTION,
377 Math.pow(-1, Number.NaN) );
379 new TestCase( SECTION,
380 "Math.pow(-1, -0.5)",
382 Math.pow(-1, -0.5) );