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.1.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.1.js
42    ECMA Section:       15.8.2.1 abs( x )
43    Description:        return the absolute value of the argument,
44    which should be the magnitude of the argument
45    with a positive sign.
46    -   if x is NaN, return NaN
47    -   if x is -0, result is +0
48    -   if x is -Infinity, result is +Infinity
49    Author:             christine@netscape.com
50    Date:               7 july 1997
51 */
52 var SECTION = "15.8.2.1";
53 var VERSION = "ECMA_1";
54 var TITLE   = "Math.abs()";
55 var BUGNUMBER = "77391";
56 startTest();
57
58 writeHeaderToLog( SECTION + " "+ TITLE);
59
60 new TestCase( SECTION,  
61               "Math.abs.length",
62               1,
63               Math.abs.length );
64
65 new TestCase( SECTION,
66               "Math.abs()", 
67               Number.NaN,
68               Math.abs() );
69
70 new TestCase( SECTION,
71               "Math.abs( void 0 )", 
72               Number.NaN,
73               Math.abs(void 0) );
74
75 new TestCase( SECTION,
76               "Math.abs( null )",  
77               0,   
78               Math.abs(null) );
79
80 new TestCase( SECTION,
81               "Math.abs( true )", 
82               1,    
83               Math.abs(true) );
84
85 new TestCase( SECTION,
86               "Math.abs( false )", 
87               0,     
88               Math.abs(false) );
89
90 new TestCase( SECTION,
91               "Math.abs( string primitive)",
92               Number.NaN, 
93               Math.abs("a string primitive") );
94
95 new TestCase( SECTION,  
96               "Math.abs( string object )",  
97               Number.NaN,    
98               Math.abs(new String( 'a String object' ))  );
99
100 new TestCase( SECTION,  
101               "Math.abs( Number.NaN )", 
102               Number.NaN,
103               Math.abs(Number.NaN) );
104
105 new TestCase( SECTION,
106               "Math.abs(0)", 
107               0,
108               Math.abs( 0 ) );
109
110 new TestCase( SECTION, 
111               "Math.abs( -0 )", 
112               0,  
113               Math.abs(-0) );
114
115 new TestCase( SECTION,  
116               "Infinity/Math.abs(-0)",
117               Infinity, 
118               Infinity/Math.abs(-0) );
119
120 new TestCase( SECTION,  
121               "Math.abs( -Infinity )",      
122               Number.POSITIVE_INFINITY,  
123               Math.abs( Number.NEGATIVE_INFINITY ) );
124
125 new TestCase( SECTION,  
126               "Math.abs( Infinity )",  
127               Number.POSITIVE_INFINITY,
128               Math.abs( Number.POSITIVE_INFINITY ) );
129
130 new TestCase( SECTION,  
131               "Math.abs( - MAX_VALUE )",   
132               Number.MAX_VALUE,
133               Math.abs( - Number.MAX_VALUE )       );
134
135 new TestCase( SECTION,  
136               "Math.abs( - MIN_VALUE )",
137               Number.MIN_VALUE,
138               Math.abs( -Number.MIN_VALUE )        );
139
140 new TestCase( SECTION,  
141               "Math.abs( MAX_VALUE )",  
142               Number.MAX_VALUE,  
143               Math.abs( Number.MAX_VALUE )       );
144
145 new TestCase( SECTION, 
146               "Math.abs( MIN_VALUE )",
147               Number.MIN_VALUE, 
148               Math.abs( Number.MIN_VALUE )        );
149
150 new TestCase( SECTION,  
151               "Math.abs( -1 )",    
152               1,   
153               Math.abs( -1 )                       );
154
155 new TestCase( SECTION,  
156               "Math.abs( new Number( -1 ) )",
157               1,   
158               Math.abs( new Number(-1) )           );
159
160 new TestCase( SECTION,  
161               "Math.abs( 1 )",  
162               1, 
163               Math.abs( 1 ) );
164
165 new TestCase( SECTION,  
166               "Math.abs( Math.PI )", 
167               Math.PI,   
168               Math.abs( Math.PI ) );
169
170 new TestCase( SECTION,
171               "Math.abs( -Math.PI )", 
172               Math.PI,  
173               Math.abs( -Math.PI ) );
174
175 new TestCase( SECTION,
176               "Math.abs(-1/100000000)",
177               1/100000000,  
178               Math.abs(-1/100000000) );
179
180 new TestCase( SECTION,
181               "Math.abs(-Math.pow(2,32))", 
182               Math.pow(2,32),    
183               Math.abs(-Math.pow(2,32)) );
184
185 new TestCase( SECTION,  
186               "Math.abs(Math.pow(2,32))",
187               Math.pow(2,32), 
188               Math.abs(Math.pow(2,32)) );
189
190 new TestCase( SECTION,
191               "Math.abs( -0xfff )", 
192               4095,    
193               Math.abs( -0xfff ) );
194
195 new TestCase( SECTION,
196               "Math.abs( -0777 )", 
197               511,   
198               Math.abs(-0777 ) );
199
200 new TestCase( SECTION,
201               "Math.abs('-1e-1')",  
202               0.1,  
203               Math.abs('-1e-1') );
204
205 new TestCase( SECTION, 
206               "Math.abs('0xff')",  
207               255,  
208               Math.abs('0xff') );
209
210 new TestCase( SECTION,
211               "Math.abs('077')",   
212               77,   
213               Math.abs('077') );
214
215 new TestCase( SECTION, 
216               "Math.abs( 'Infinity' )",
217               Infinity,
218               Math.abs('Infinity') );
219
220 new TestCase( SECTION,
221               "Math.abs( '-Infinity' )",
222               Infinity,
223               Math.abs('-Infinity') );
224
225 test();