initial import
[vuplus_webkit] / Source / JavaScriptCore / tests / mozilla / ecma / Math / 15.8.2.7.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/
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.7.js
24     ECMA Section:       15.8.2.7 cos( x )
25     Description:        return an approximation to the cosine of the
26                         argument.  argument is expressed in radians
27     Author:             christine@netscape.com
28     Date:               7 july 1997
29
30 */
31
32     var SECTION = "15.8.2.7";
33     var VERSION = "ECMA_1";
34     startTest();
35     var TITLE   = "Math.cos(x)";
36
37     writeHeaderToLog( SECTION + " "+ TITLE);
38
39     var testcases = getTestCases();
40     test();
41
42 function getTestCases() {
43     var array = new Array();
44     var item = 0;
45
46     array[item++] = new TestCase( SECTION, "Math.cos.length",       1,                      Math.cos.length );
47
48     array[item++] = new TestCase( SECTION, "Math.cos()",            Number.NaN,             Math.cos() );
49     array[item++] = new TestCase( SECTION, "Math.cos(void 0)",      Number.NaN,             Math.cos(void 0) );
50     array[item++] = new TestCase( SECTION, "Math.cos(false)",       1,                      Math.cos(false) );
51     array[item++] = new TestCase( SECTION, "Math.cos(null)",        1,                      Math.cos(null) );
52
53     array[item++] = new TestCase( SECTION, "Math.cos('0')",         1,                      Math.cos('0') );
54     array[item++] = new TestCase( SECTION, "Math.cos('Infinity')",  Number.NaN,             Math.cos("Infinity") );
55     array[item++] = new TestCase( SECTION, "Math.cos('3.14159265359')",  -1,                 Math.cos('3.14159265359') );
56
57     array[item++] = new TestCase( SECTION, "Math.cos(NaN)",          Number.NaN,             Math.cos(Number.NaN)        );
58     array[item++] = new TestCase( SECTION, "Math.cos(0)",            1,                      Math.cos(0)                 );
59     array[item++] = new TestCase( SECTION, "Math.cos(-0)",           1,                      Math.cos(-0)                );
60     array[item++] = new TestCase( SECTION, "Math.cos(Infinity)",     Number.NaN,             Math.cos(Number.POSITIVE_INFINITY) );
61     array[item++] = new TestCase( SECTION, "Math.cos(-Infinity)",    Number.NaN,             Math.cos(Number.NEGATIVE_INFINITY) );
62     array[item++] = new TestCase( SECTION, "Math.cos(0.7853981633974)", 0.7071067811865,    Math.cos(0.7853981633974)   );
63     array[item++] = new TestCase( SECTION, "Math.cos(1.570796326795)",   0,                  Math.cos(1.570796326795)    );
64     array[item++] = new TestCase( SECTION, "Math.cos(2.356194490192)",  -0.7071067811865,   Math.cos(2.356194490192)    );
65     array[item++] = new TestCase( SECTION, "Math.cos(3.14159265359)",   -1,                 Math.cos(3.14159265359)     );
66     array[item++] = new TestCase( SECTION, "Math.cos(3.926990816987)",  -0.7071067811865,   Math.cos(3.926990816987)    );
67     array[item++] = new TestCase( SECTION, "Math.cos(4.712388980385)",  0,                  Math.cos(4.712388980385)    );
68     array[item++] = new TestCase( SECTION, "Math.cos(5.497787143782)",  0.7071067811865,    Math.cos(5.497787143782)    );
69     array[item++] = new TestCase( SECTION, "Math.cos(Math.PI*2)",           1,                  Math.cos(Math.PI*2)         );
70     array[item++] = new TestCase( SECTION, "Math.cos(Math.PI/4)",           Math.SQRT2/2,       Math.cos(Math.PI/4)         );
71     array[item++] = new TestCase( SECTION, "Math.cos(Math.PI/2)",           0,                  Math.cos(Math.PI/2)         );
72     array[item++] = new TestCase( SECTION, "Math.cos(3*Math.PI/4)",         -Math.SQRT2/2,      Math.cos(3*Math.PI/4)       );
73     array[item++] = new TestCase( SECTION, "Math.cos(Math.PI)",         -1,                 Math.cos(Math.PI)           );
74     array[item++] = new TestCase( SECTION, "Math.cos(5*Math.PI/4)",         -Math.SQRT2/2,      Math.cos(5*Math.PI/4)       );
75     array[item++] = new TestCase( SECTION, "Math.cos(3*Math.PI/2)",         0,                  Math.cos(3*Math.PI/2)       );
76     array[item++] = new TestCase( SECTION, "Math.cos(7*Math.PI/4)",         Math.SQRT2/2,       Math.cos(7*Math.PI/4)       );
77     array[item++] = new TestCase( SECTION, "Math.cos(Math.PI*2)",           1,                  Math.cos(2*Math.PI)         );
78     array[item++] = new TestCase( SECTION, "Math.cos(-0.7853981633974)",        0.7071067811865,    Math.cos(-0.7853981633974)  );
79     array[item++] = new TestCase( SECTION, "Math.cos(-1.570796326795)", 0,                  Math.cos(-1.570796326795)   );
80     array[item++] = new TestCase( SECTION, "Math.cos(-2.3561944901920)",        -.7071067811865,    Math.cos(2.3561944901920)   );
81     array[item++] = new TestCase( SECTION, "Math.cos(-3.14159265359)",  -1,                 Math.cos(3.14159265359)     );
82     array[item++] = new TestCase( SECTION, "Math.cos(-3.926990816987)", -0.7071067811865,   Math.cos(3.926990816987)    );
83     array[item++] = new TestCase( SECTION, "Math.cos(-4.712388980385)", 0,                  Math.cos(4.712388980385)    );
84     array[item++] = new TestCase( SECTION, "Math.cos(-5.497787143782)", 0.7071067811865,    Math.cos(5.497787143782)    );
85     array[item++] = new TestCase( SECTION, "Math.cos(-6.28318530718)",  1,                  Math.cos(6.28318530718)     );
86     array[item++] = new TestCase( SECTION, "Math.cos(-Math.PI/4)",          Math.SQRT2/2,       Math.cos(-Math.PI/4)        );
87     array[item++] = new TestCase( SECTION, "Math.cos(-Math.PI/2)",          0,                  Math.cos(-Math.PI/2)        );
88     array[item++] = new TestCase( SECTION, "Math.cos(-3*Math.PI/4)",        -Math.SQRT2/2,      Math.cos(-3*Math.PI/4)      );
89     array[item++] = new TestCase( SECTION, "Math.cos(-Math.PI)",                -1,                 Math.cos(-Math.PI)          );
90     array[item++] = new TestCase( SECTION, "Math.cos(-5*Math.PI/4)",        -Math.SQRT2/2,      Math.cos(-5*Math.PI/4)      );
91     array[item++] = new TestCase( SECTION, "Math.cos(-3*Math.PI/2)",        0,                  Math.cos(-3*Math.PI/2)      );
92     array[item++] = new TestCase( SECTION, "Math.cos(-7*Math.PI/4)",        Math.SQRT2/2,       Math.cos(-7*Math.PI/4)      );
93     array[item++] = new TestCase( SECTION, "Math.cos(-Math.PI*2)",          1,                  Math.cos(-Math.PI*2)        );
94
95     return ( array );
96 }
97
98
99 function test() {
100     for ( tc=0; tc < testcases.length; tc++ ) {
101         testcases[tc].passed = writeTestCaseResult(
102                             testcases[tc].expect,
103                             testcases[tc].actual,
104                             testcases[tc].description +" = "+
105                             testcases[tc].actual );
106
107         testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
108     }
109     stopTest();
110     return ( testcases );
111 }