]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/Math/15.8.2.2.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
23 File Name: 15.8.2.2.js
24 ECMA Section: 15.8.2.2 acos( x )
25 Description: return an approximation to the arc cosine of the
26 argument. the result is expressed in radians and
27 range is from +0 to +PI. special cases:
28 - if x is NaN, return NaN
29 - if x > 1, the result is NaN
30 - if x < -1, the result is NaN
31 - if x == 1, the result is +0
32 Author: christine@netscape.com
35 var SECTION
= "15.8.2.2";
36 var VERSION
= "ECMA_1";
38 var TITLE
= "Math.acos()";
40 writeHeaderToLog( SECTION
+ " "+ TITLE
);
42 var testcases
= getTestCases();
45 function getTestCases() {
46 var array
= new Array();
49 array
[item
++] = new TestCase( SECTION
, "Math.acos.length", 1, Math
.acos
.length
);
51 array
[item
++] = new TestCase( SECTION
, "Math.acos(void 0)", Number
.NaN
, Math
.acos(void 0) );
52 array
[item
++] = new TestCase( SECTION
, "Math.acos()", Number
.NaN
, Math
.acos() );
53 array
[item
++] = new TestCase( SECTION
, "Math.acos(null)", Math
.PI
/2, Math
.acos(null) );
54 array
[item
++] = new TestCase( SECTION
, "Math.acos(NaN)", Number
.NaN
, Math
.acos(Number
.NaN
) );
56 array
[item
++] = new TestCase( SECTION
, "Math.acos(a string)", Number
.NaN
, Math
.acos("a string") );
57 array
[item
++] = new TestCase( SECTION
, "Math.acos('0')", Math
.PI
/2, Math
.acos('0') );
58 array
[item
++] = new TestCase( SECTION
, "Math.acos('1')", 0, Math
.acos('1') );
59 array
[item
++] = new TestCase( SECTION
, "Math.acos('-1')", Math
.PI
, Math
.acos('-1') );
61 array
[item
++] = new TestCase( SECTION
, "Math.acos(1.00000001)", Number
.NaN
, Math
.acos(1.00000001) );
62 array
[item
++] = new TestCase( SECTION
, "Math.acos(11.00000001)", Number
.NaN
, Math
.acos(-1.00000001) );
63 array
[item
++] = new TestCase( SECTION
, "Math.acos(1)", 0, Math
.acos(1) );
64 array
[item
++] = new TestCase( SECTION
, "Math.acos(-1)", Math
.PI
, Math
.acos(-1) );
65 array
[item
++] = new TestCase( SECTION
, "Math.acos(0)", Math
.PI
/2, Math
.acos(0) );
66 array
[item
++] = new TestCase( SECTION
, "Math.acos(-0)", Math
.PI
/2, Math
.acos(-0) );
67 array
[item
++] = new TestCase( SECTION
, "Math.acos(Math.SQRT1_2)", Math
.PI
/4, Math
.acos(Math
.SQRT1_2
));
68 array
[item
++] = new TestCase( SECTION
, "Math.acos(-Math.SQRT1_2)", Math
.PI
/4*3, Math
.acos(-Math
.SQRT1_2
));
69 array
[item
++] = new TestCase( SECTION
, "Math.acos(0.9999619230642)", Math
.PI
/360, Math
.acos(0.9999619230642));
75 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
76 testcases
[tc
].passed
= writeTestCaseResult(
79 testcases
[tc
].description
+" = "+
80 testcases
[tc
].actual
);
82 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";