Merge "fix: the incorrect version of tarball generated by gbs export" into tizen
[platform/upstream/js.git] / js / src / tests / ecma / Math / 15.8.2.13.js
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
4  *
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/
9  *
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
13  * License.
14  *
15  * The Original Code is Mozilla Communicator client code, released
16  * March 31, 1998.
17  *
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.
22  *
23  * Contributor(s):
24  *
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.
36  *
37  * ***** END LICENSE BLOCK ***** */
38
39
40 /**
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;
45    refer to the spec.
46    Author:             christine@netscape.com
47    Date:               9 july 1997
48 */
49
50 var SECTION = "15.8.2.13";
51 var VERSION = "ECMA_1";
52 var TITLE   = "Math.pow(x, y)";
53 var BUGNUMBER="77141";
54
55 startTest();
56
57 writeHeaderToLog( SECTION + " "+ TITLE);
58
59 new TestCase( SECTION,
60               "Math.pow.length",
61               2,
62               Math.pow.length );
63
64 new TestCase( SECTION,
65               "Math.pow()",
66               Number.NaN,
67               Math.pow() );
68
69 new TestCase( SECTION,
70               "Math.pow(null, null)",
71               1,
72               Math.pow(null,null) );
73
74 new TestCase( SECTION, 
75               "Math.pow(void 0, void 0)",
76               Number.NaN,
77               Math.pow(void 0, void 0));
78
79 new TestCase( SECTION, 
80               "Math.pow(true, false)",
81               1,
82               Math.pow(true, false) );
83
84 new TestCase( SECTION, 
85               "Math.pow(false,true)",
86               0,
87               Math.pow(false,true) );
88
89 new TestCase( SECTION, 
90               "Math.pow('2','32')",
91               4294967296,
92               Math.pow('2','32') );
93
94 new TestCase( SECTION, 
95               "Math.pow(1,NaN)",
96               Number.NaN,
97               Math.pow(1,Number.NaN) );
98
99 new TestCase( SECTION, 
100               "Math.pow(0,NaN)",        
101               Number.NaN,
102               Math.pow(0,Number.NaN) );
103
104 new TestCase( SECTION, 
105               "Math.pow(NaN,0)",
106               1,
107               Math.pow(Number.NaN,0) );
108
109 new TestCase( SECTION,
110               "Math.pow(NaN,-0)",
111               1,
112               Math.pow(Number.NaN,-0) );
113
114 new TestCase( SECTION, 
115               "Math.pow(NaN,1)",
116               Number.NaN,
117               Math.pow(Number.NaN, 1) );
118
119 new TestCase( SECTION, 
120               "Math.pow(NaN,.5)",
121               Number.NaN,
122               Math.pow(Number.NaN, .5) );
123
124 new TestCase( SECTION, 
125               "Math.pow(1.00000001, Infinity)",
126               Number.POSITIVE_INFINITY,
127               Math.pow(1.00000001, Number.POSITIVE_INFINITY) );
128
129 new TestCase( SECTION, 
130               "Math.pow(1.00000001, -Infinity)", 
131               0,
132               Math.pow(1.00000001, Number.NEGATIVE_INFINITY) );
133
134 new TestCase( SECTION, 
135               "Math.pow(-1.00000001, Infinity)", 
136               Number.POSITIVE_INFINITY,
137               Math.pow(-1.00000001,Number.POSITIVE_INFINITY) );
138
139 new TestCase( SECTION, 
140               "Math.pow(-1.00000001, -Infinity)",
141               0,
142               Math.pow(-1.00000001,Number.NEGATIVE_INFINITY) );
143
144 new TestCase( SECTION, 
145               "Math.pow(1, Infinity)",
146               Number.NaN,
147               Math.pow(1, Number.POSITIVE_INFINITY) );
148
149 new TestCase( SECTION, 
150               "Math.pow(1, -Infinity)",
151               Number.NaN,
152               Math.pow(1, Number.NEGATIVE_INFINITY) );
153
154 new TestCase( SECTION, 
155               "Math.pow(-1, Infinity)",
156               Number.NaN,
157               Math.pow(-1, Number.POSITIVE_INFINITY) );
158
159 new TestCase( SECTION, 
160               "Math.pow(-1, -Infinity)",
161               Number.NaN,
162               Math.pow(-1, Number.NEGATIVE_INFINITY) );
163
164 new TestCase( SECTION, 
165               "Math.pow(.0000000009, Infinity)", 
166               0,
167               Math.pow(.0000000009, Number.POSITIVE_INFINITY) );
168
169 new TestCase( SECTION, 
170               "Math.pow(-.0000000009, Infinity)",
171               0,
172               Math.pow(-.0000000009, Number.POSITIVE_INFINITY) );
173
174 new TestCase( SECTION, 
175               "Math.pow(.0000000009, -Infinity)",
176               Number.POSITIVE_INFINITY,
177               Math.pow(-.0000000009, Number.NEGATIVE_INFINITY) );
178
179 new TestCase( SECTION, 
180               "Math.pow(Infinity, .00000000001)",
181               Number.POSITIVE_INFINITY,
182               Math.pow(Number.POSITIVE_INFINITY,.00000000001) );
183
184 new TestCase( SECTION, 
185               "Math.pow(Infinity, 1)",
186               Number.POSITIVE_INFINITY,
187               Math.pow(Number.POSITIVE_INFINITY, 1) );
188
189 new TestCase( SECTION, 
190               "Math.pow(Infinity, -.00000000001)",
191               0,
192               Math.pow(Number.POSITIVE_INFINITY, -.00000000001) );
193
194 new TestCase( SECTION, 
195               "Math.pow(Infinity, -1)",
196               0,
197               Math.pow(Number.POSITIVE_INFINITY, -1) );
198
199 new TestCase( SECTION, 
200               "Math.pow(-Infinity, 1)",
201               Number.NEGATIVE_INFINITY,
202               Math.pow(Number.NEGATIVE_INFINITY, 1) );
203
204 new TestCase( SECTION, 
205               "Math.pow(-Infinity, 333)",
206               Number.NEGATIVE_INFINITY,
207               Math.pow(Number.NEGATIVE_INFINITY, 333) );
208
209 new TestCase( SECTION, 
210               "Math.pow(Infinity, 2)",
211               Number.POSITIVE_INFINITY,
212               Math.pow(Number.POSITIVE_INFINITY, 2) );
213
214 new TestCase( SECTION, 
215               "Math.pow(-Infinity, 666)",
216               Number.POSITIVE_INFINITY,
217               Math.pow(Number.NEGATIVE_INFINITY, 666) );
218
219 new TestCase( SECTION, 
220               "Math.pow(-Infinity, 0.5)",
221               Number.POSITIVE_INFINITY,
222               Math.pow(Number.NEGATIVE_INFINITY, 0.5) );
223
224 new TestCase( SECTION, 
225               "Math.pow(-Infinity, Infinity)",
226               Number.POSITIVE_INFINITY,
227               Math.pow(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) );
228
229 new TestCase( SECTION, 
230               "Math.pow(-Infinity, -1)",
231               -0,
232               Math.pow(Number.NEGATIVE_INFINITY, -1) );
233
234 new TestCase( SECTION, 
235               "Infinity/Math.pow(-Infinity, -1)",
236               -Infinity,
237               Infinity/Math.pow(Number.NEGATIVE_INFINITY, -1) );
238
239 new TestCase( SECTION, 
240               "Math.pow(-Infinity, -3)",
241               -0,
242               Math.pow(Number.NEGATIVE_INFINITY, -3) );
243
244 new TestCase( SECTION, 
245               "Math.pow(-Infinity, -2)",
246               0,
247               Math.pow(Number.NEGATIVE_INFINITY, -2) );
248
249 new TestCase( SECTION, 
250               "Math.pow(-Infinity, -0.5)",
251               0,
252               Math.pow(Number.NEGATIVE_INFINITY,-0.5) );
253
254 new TestCase( SECTION, 
255               "Math.pow(-Infinity, -Infinity)",
256               0,
257               Math.pow(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) );
258
259 new TestCase( SECTION, 
260               "Math.pow(0, 1)",
261               0,
262               Math.pow(0,1) );
263
264 new TestCase( SECTION, 
265               "Math.pow(0, 0)",
266               1,
267               Math.pow(0,0) );
268
269 new TestCase( SECTION, 
270               "Math.pow(1, 0)",
271               1,
272               Math.pow(1,0) );
273
274 new TestCase( SECTION,
275               "Math.pow(-1, 0)",
276               1,
277               Math.pow(-1,0) );
278
279 new TestCase( SECTION, 
280               "Math.pow(0, 0.5)",
281               0,
282               Math.pow(0,0.5) );
283
284 new TestCase( SECTION, 
285               "Math.pow(0, 1000)",
286               0,
287               Math.pow(0,1000) );
288
289 new TestCase( SECTION,
290               "Math.pow(0, Infinity)",
291               0,
292               Math.pow(0, Number.POSITIVE_INFINITY) );
293
294 new TestCase( SECTION, 
295               "Math.pow(0, -1)",
296               Number.POSITIVE_INFINITY,
297               Math.pow(0, -1) );
298
299 new TestCase( SECTION, 
300               "Math.pow(0, -0.5)",
301               Number.POSITIVE_INFINITY,
302               Math.pow(0, -0.5) );
303
304 new TestCase( SECTION, 
305               "Math.pow(0, -1000)",
306               Number.POSITIVE_INFINITY,
307               Math.pow(0, -1000) );
308
309 new TestCase( SECTION, 
310               "Math.pow(0, -Infinity)",
311               Number.POSITIVE_INFINITY,
312               Math.pow(0, Number.NEGATIVE_INFINITY) );
313
314 new TestCase( SECTION, 
315               "Math.pow(-0, 1)",
316               -0,
317               Math.pow(-0, 1) );
318
319 new TestCase( SECTION, 
320               "Math.pow(-0, 3)",
321               -0,
322               Math.pow(-0,3) );
323
324 new TestCase( SECTION, 
325               "Infinity/Math.pow(-0, 1)",
326               -Infinity,
327               Infinity/Math.pow(-0, 1) );
328
329 new TestCase( SECTION, 
330               "Infinity/Math.pow(-0, 3)",
331               -Infinity,
332               Infinity/Math.pow(-0,3) );
333
334 new TestCase( SECTION, 
335               "Math.pow(-0, 2)",
336               0,
337               Math.pow(-0,2) );
338
339 new TestCase( SECTION, 
340               "Math.pow(-0, Infinity)",
341               0,
342               Math.pow(-0, Number.POSITIVE_INFINITY) );
343
344 new TestCase( SECTION, 
345               "Math.pow(-0, -1)",
346               Number.NEGATIVE_INFINITY,
347               Math.pow(-0, -1) );
348
349 new TestCase( SECTION, 
350               "Math.pow(-0, -10001)",
351               Number.NEGATIVE_INFINITY,
352               Math.pow(-0, -10001) );
353
354 new TestCase( SECTION, 
355               "Math.pow(-0, -2)",
356               Number.POSITIVE_INFINITY,
357               Math.pow(-0, -2) );
358
359 new TestCase( SECTION, 
360               "Math.pow(-0, 0.5)",
361               0,
362               Math.pow(-0, 0.5) );
363
364 new TestCase( SECTION, 
365               "Math.pow(-0, Infinity)",
366               0,
367               Math.pow(-0, Number.POSITIVE_INFINITY) );
368
369 new TestCase( SECTION, 
370               "Math.pow(-1, 0.5)",
371               Number.NaN,
372               Math.pow(-1, 0.5) );
373
374 new TestCase( SECTION, 
375               "Math.pow(-1, NaN)",
376               Number.NaN,
377               Math.pow(-1, Number.NaN) );
378
379 new TestCase( SECTION, 
380               "Math.pow(-1, -0.5)",
381               Number.NaN,
382               Math.pow(-1, -0.5) );
383
384 test();