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.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
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
52 var SECTION = "15.8.2.1";
53 var VERSION = "ECMA_1";
54 var TITLE = "Math.abs()";
55 var BUGNUMBER = "77391";
58 writeHeaderToLog( SECTION + " "+ TITLE);
60 new TestCase( SECTION,
65 new TestCase( SECTION,
70 new TestCase( SECTION,
75 new TestCase( SECTION,
80 new TestCase( SECTION,
85 new TestCase( SECTION,
90 new TestCase( SECTION,
91 "Math.abs( string primitive)",
93 Math.abs("a string primitive") );
95 new TestCase( SECTION,
96 "Math.abs( string object )",
98 Math.abs(new String( 'a String object' )) );
100 new TestCase( SECTION,
101 "Math.abs( Number.NaN )",
103 Math.abs(Number.NaN) );
105 new TestCase( SECTION,
110 new TestCase( SECTION,
115 new TestCase( SECTION,
116 "Infinity/Math.abs(-0)",
118 Infinity/Math.abs(-0) );
120 new TestCase( SECTION,
121 "Math.abs( -Infinity )",
122 Number.POSITIVE_INFINITY,
123 Math.abs( Number.NEGATIVE_INFINITY ) );
125 new TestCase( SECTION,
126 "Math.abs( Infinity )",
127 Number.POSITIVE_INFINITY,
128 Math.abs( Number.POSITIVE_INFINITY ) );
130 new TestCase( SECTION,
131 "Math.abs( - MAX_VALUE )",
133 Math.abs( - Number.MAX_VALUE ) );
135 new TestCase( SECTION,
136 "Math.abs( - MIN_VALUE )",
138 Math.abs( -Number.MIN_VALUE ) );
140 new TestCase( SECTION,
141 "Math.abs( MAX_VALUE )",
143 Math.abs( Number.MAX_VALUE ) );
145 new TestCase( SECTION,
146 "Math.abs( MIN_VALUE )",
148 Math.abs( Number.MIN_VALUE ) );
150 new TestCase( SECTION,
155 new TestCase( SECTION,
156 "Math.abs( new Number( -1 ) )",
158 Math.abs( new Number(-1) ) );
160 new TestCase( SECTION,
165 new TestCase( SECTION,
166 "Math.abs( Math.PI )",
168 Math.abs( Math.PI ) );
170 new TestCase( SECTION,
171 "Math.abs( -Math.PI )",
173 Math.abs( -Math.PI ) );
175 new TestCase( SECTION,
176 "Math.abs(-1/100000000)",
178 Math.abs(-1/100000000) );
180 new TestCase( SECTION,
181 "Math.abs(-Math.pow(2,32))",
183 Math.abs(-Math.pow(2,32)) );
185 new TestCase( SECTION,
186 "Math.abs(Math.pow(2,32))",
188 Math.abs(Math.pow(2,32)) );
190 new TestCase( SECTION,
191 "Math.abs( -0xfff )",
193 Math.abs( -0xfff ) );
195 new TestCase( SECTION,
200 new TestCase( SECTION,
205 new TestCase( SECTION,
210 new TestCase( SECTION,
215 new TestCase( SECTION,
216 "Math.abs( 'Infinity' )",
218 Math.abs('Infinity') );
220 new TestCase( SECTION,
221 "Math.abs( '-Infinity' )",
223 Math.abs('-Infinity') );