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/
5 *
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.
10 *
11 * The Original Code is Mozilla Communicator client code, released March
12 * 31, 1998.
13 *
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
17 * Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 */
22/**
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
33    Date:               7 july 1997
34*/
35    var SECTION = "15.8.2.2";
36    var VERSION = "ECMA_1";
37    startTest();
38    var TITLE   = "Math.acos()";
39
40    writeHeaderToLog( SECTION + " "+ TITLE);
41
42    var testcases = getTestCases();
43    test();
44
45function getTestCases() {
46    var array = new Array();
47    var item = 0;
48
49    array[item++] = new TestCase( SECTION,  "Math.acos.length",         1,              Math.acos.length );
50
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) );
55
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') );
60
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));
70
71    return ( array );
72}
73
74function test() {
75    for ( tc=0; tc < testcases.length; tc++ ) {
76        testcases[tc].passed = writeTestCaseResult(
77                            testcases[tc].expect,
78                            testcases[tc].actual,
79                            testcases[tc].description +" = "+
80                            testcases[tc].actual );
81
82        testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
83    }
84    stopTest();
85    return ( testcases );
86}
87