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 ***** */
39 gTestfile = '15.8.2.13.js';
42 File Name: 15.8.2.13.js
43 ECMA Section: 15.8.2.13 Math.pow(x, y)
44 Description: return an approximation to the result of x
45 to the power of y. there are many special cases;
47 Author: christine@netscape.com
51 var SECTION = "15.8.2.13";
52 var VERSION = "ECMA_1";
53 var TITLE = "Math.pow(x, y)";
54 var BUGNUMBER="77141";
58 writeHeaderToLog( SECTION + " "+ TITLE);
60 new TestCase( SECTION,
65 new TestCase( SECTION,
70 new TestCase( SECTION,
71 "Math.pow(null, null)",
73 Math.pow(null,null) );
75 new TestCase( SECTION,
76 "Math.pow(void 0, void 0)",
78 Math.pow(void 0, void 0));
80 new TestCase( SECTION,
81 "Math.pow(true, false)",
83 Math.pow(true, false) );
85 new TestCase( SECTION,
86 "Math.pow(false,true)",
88 Math.pow(false,true) );
90 new TestCase( SECTION,
95 new TestCase( SECTION,
98 Math.pow(1,Number.NaN) );
100 new TestCase( SECTION,
103 Math.pow(0,Number.NaN) );
105 new TestCase( SECTION,
108 Math.pow(Number.NaN,0) );
110 new TestCase( SECTION,
113 Math.pow(Number.NaN,-0) );
115 new TestCase( SECTION,
118 Math.pow(Number.NaN, 1) );
120 new TestCase( SECTION,
123 Math.pow(Number.NaN, .5) );
125 new TestCase( SECTION,
126 "Math.pow(1.00000001, Infinity)",
127 Number.POSITIVE_INFINITY,
128 Math.pow(1.00000001, Number.POSITIVE_INFINITY) );
130 new TestCase( SECTION,
131 "Math.pow(1.00000001, -Infinity)",
133 Math.pow(1.00000001, Number.NEGATIVE_INFINITY) );
135 new TestCase( SECTION,
136 "Math.pow(-1.00000001, Infinity)",
137 Number.POSITIVE_INFINITY,
138 Math.pow(-1.00000001,Number.POSITIVE_INFINITY) );
140 new TestCase( SECTION,
141 "Math.pow(-1.00000001, -Infinity)",
143 Math.pow(-1.00000001,Number.NEGATIVE_INFINITY) );
145 new TestCase( SECTION,
146 "Math.pow(1, Infinity)",
148 Math.pow(1, Number.POSITIVE_INFINITY) );
150 new TestCase( SECTION,
151 "Math.pow(1, -Infinity)",
153 Math.pow(1, Number.NEGATIVE_INFINITY) );
155 new TestCase( SECTION,
156 "Math.pow(-1, Infinity)",
158 Math.pow(-1, Number.POSITIVE_INFINITY) );
160 new TestCase( SECTION,
161 "Math.pow(-1, -Infinity)",
163 Math.pow(-1, Number.NEGATIVE_INFINITY) );
165 new TestCase( SECTION,
166 "Math.pow(.0000000009, Infinity)",
168 Math.pow(.0000000009, Number.POSITIVE_INFINITY) );
170 new TestCase( SECTION,
171 "Math.pow(-.0000000009, Infinity)",
173 Math.pow(-.0000000009, Number.POSITIVE_INFINITY) );
175 new TestCase( SECTION,
176 "Math.pow(.0000000009, -Infinity)",
177 Number.POSITIVE_INFINITY,
178 Math.pow(-.0000000009, Number.NEGATIVE_INFINITY) );
180 new TestCase( SECTION,
181 "Math.pow(Infinity, .00000000001)",
182 Number.POSITIVE_INFINITY,
183 Math.pow(Number.POSITIVE_INFINITY,.00000000001) );
185 new TestCase( SECTION,
186 "Math.pow(Infinity, 1)",
187 Number.POSITIVE_INFINITY,
188 Math.pow(Number.POSITIVE_INFINITY, 1) );
190 new TestCase( SECTION,
191 "Math.pow(Infinity, -.00000000001)",
193 Math.pow(Number.POSITIVE_INFINITY, -.00000000001) );
195 new TestCase( SECTION,
196 "Math.pow(Infinity, -1)",
198 Math.pow(Number.POSITIVE_INFINITY, -1) );
200 new TestCase( SECTION,
201 "Math.pow(-Infinity, 1)",
202 Number.NEGATIVE_INFINITY,
203 Math.pow(Number.NEGATIVE_INFINITY, 1) );
205 new TestCase( SECTION,
206 "Math.pow(-Infinity, 333)",
207 Number.NEGATIVE_INFINITY,
208 Math.pow(Number.NEGATIVE_INFINITY, 333) );
210 new TestCase( SECTION,
211 "Math.pow(Infinity, 2)",
212 Number.POSITIVE_INFINITY,
213 Math.pow(Number.POSITIVE_INFINITY, 2) );
215 new TestCase( SECTION,
216 "Math.pow(-Infinity, 666)",
217 Number.POSITIVE_INFINITY,
218 Math.pow(Number.NEGATIVE_INFINITY, 666) );
220 new TestCase( SECTION,
221 "Math.pow(-Infinity, 0.5)",
222 Number.POSITIVE_INFINITY,
223 Math.pow(Number.NEGATIVE_INFINITY, 0.5) );
225 new TestCase( SECTION,
226 "Math.pow(-Infinity, Infinity)",
227 Number.POSITIVE_INFINITY,
228 Math.pow(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) );
230 new TestCase( SECTION,
231 "Math.pow(-Infinity, -1)",
233 Math.pow(Number.NEGATIVE_INFINITY, -1) );
235 new TestCase( SECTION,
236 "Infinity/Math.pow(-Infinity, -1)",
238 Infinity/Math.pow(Number.NEGATIVE_INFINITY, -1) );
240 new TestCase( SECTION,
241 "Math.pow(-Infinity, -3)",
243 Math.pow(Number.NEGATIVE_INFINITY, -3) );
245 new TestCase( SECTION,
246 "Math.pow(-Infinity, -2)",
248 Math.pow(Number.NEGATIVE_INFINITY, -2) );
250 new TestCase( SECTION,
251 "Math.pow(-Infinity, -0.5)",
253 Math.pow(Number.NEGATIVE_INFINITY,-0.5) );
255 new TestCase( SECTION,
256 "Math.pow(-Infinity, -Infinity)",
258 Math.pow(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) );
260 new TestCase( SECTION,
265 new TestCase( SECTION,
270 new TestCase( SECTION,
275 new TestCase( SECTION,
280 new TestCase( SECTION,
285 new TestCase( SECTION,
290 new TestCase( SECTION,
291 "Math.pow(0, Infinity)",
293 Math.pow(0, Number.POSITIVE_INFINITY) );
295 new TestCase( SECTION,
297 Number.POSITIVE_INFINITY,
300 new TestCase( SECTION,
302 Number.POSITIVE_INFINITY,
305 new TestCase( SECTION,
306 "Math.pow(0, -1000)",
307 Number.POSITIVE_INFINITY,
308 Math.pow(0, -1000) );
310 new TestCase( SECTION,
311 "Math.pow(0, -Infinity)",
312 Number.POSITIVE_INFINITY,
313 Math.pow(0, Number.NEGATIVE_INFINITY) );
315 new TestCase( SECTION,
320 new TestCase( SECTION,
325 new TestCase( SECTION,
326 "Infinity/Math.pow(-0, 1)",
328 Infinity/Math.pow(-0, 1) );
330 new TestCase( SECTION,
331 "Infinity/Math.pow(-0, 3)",
333 Infinity/Math.pow(-0,3) );
335 new TestCase( SECTION,
340 new TestCase( SECTION,
341 "Math.pow(-0, Infinity)",
343 Math.pow(-0, Number.POSITIVE_INFINITY) );
345 new TestCase( SECTION,
347 Number.NEGATIVE_INFINITY,
350 new TestCase( SECTION,
351 "Math.pow(-0, -10001)",
352 Number.NEGATIVE_INFINITY,
353 Math.pow(-0, -10001) );
355 new TestCase( SECTION,
357 Number.POSITIVE_INFINITY,
360 new TestCase( SECTION,
365 new TestCase( SECTION,
366 "Math.pow(-0, Infinity)",
368 Math.pow(-0, Number.POSITIVE_INFINITY) );
370 new TestCase( SECTION,
375 new TestCase( SECTION,
378 Math.pow(-1, Number.NaN) );
380 new TestCase( SECTION,
381 "Math.pow(-1, -0.5)",
383 Math.pow(-1, -0.5) );