]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/mozilla/ecma/Math/15.8.2.3.js
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / tests / mozilla / ecma / Math / 15.8.2.3.js
CommitLineData
b37bf2e1
A
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.3.js
24 ECMA Section: 15.8.2.3 asin( x )
25 Description: return an approximation to the arc sine of the
26 argument. the result is expressed in radians and
27 range is from -PI/2 to +PI/2. special cases:
28 - if x is NaN, the result is NaN
29 - if x > 1, the result is NaN
30 - if x < -1, the result is NaN
31 - if x == +0, the result is +0
32 - if x == -0, the result is -0
33 Author: christine@netscape.com
34 Date: 7 july 1997
35
36*/
37 var SECTION = "15.8.2.3";
38 var VERSION = "ECMA_1";
39 startTest();
40 var TITLE = "Math.asin()";
41
42 writeHeaderToLog( SECTION + " "+ TITLE);
43
44 var testcases = getTestCases();
45 test();
46
47function getTestCases() {
48 var array = new Array();
49 var item = 0;
50
51 array[item++] = new TestCase( SECTION, "Math.asin()", Number.NaN, Math.asin() );
52 array[item++] = new TestCase( SECTION, "Math.asin(void 0)", Number.NaN, Math.asin(void 0) );
53 array[item++] = new TestCase( SECTION, "Math.asin(null)", 0, Math.asin(null) );
54 array[item++] = new TestCase( SECTION, "Math.asin(NaN)", Number.NaN, Math.asin(Number.NaN) );
55
56 array[item++] = new TestCase( SECTION, "Math.asin('string')", Number.NaN, Math.asin("string") );
57 array[item++] = new TestCase( SECTION, "Math.asin('0')", 0, Math.asin("0") );
58 array[item++] = new TestCase( SECTION, "Math.asin('1')", Math.PI/2, Math.asin("1") );
59 array[item++] = new TestCase( SECTION, "Math.asin('-1')", -Math.PI/2, Math.asin("-1") );
60 array[item++] = new TestCase( SECTION, "Math.asin(Math.SQRT1_2+'')", Math.PI/4, Math.asin(Math.SQRT1_2+'') );
61 array[item++] = new TestCase( SECTION, "Math.asin(-Math.SQRT1_2+'')", -Math.PI/4, Math.asin(-Math.SQRT1_2+'') );
62
63 array[item++] = new TestCase( SECTION, "Math.asin(1.000001)", Number.NaN, Math.asin(1.000001) );
64 array[item++] = new TestCase( SECTION, "Math.asin(-1.000001)", Number.NaN, Math.asin(-1.000001) );
65 array[item++] = new TestCase( SECTION, "Math.asin(0)", 0, Math.asin(0) );
66 array[item++] = new TestCase( SECTION, "Math.asin(-0)", -0, Math.asin(-0) );
67
68 array[item++] = new TestCase( SECTION, "Infinity/Math.asin(-0)", -Infinity, Infinity/Math.asin(-0) );
69
70 array[item++] = new TestCase( SECTION, "Math.asin(1)", Math.PI/2, Math.asin(1) );
71 array[item++] = new TestCase( SECTION, "Math.asin(-1)", -Math.PI/2, Math.asin(-1) );
72 array[item++] = new TestCase( SECTION, "Math.asin(Math.SQRT1_2))", Math.PI/4, Math.asin(Math.SQRT1_2) );
73 array[item++] = new TestCase( SECTION, "Math.asin(-Math.SQRT1_2))", -Math.PI/4, Math.asin(-Math.SQRT1_2));
74
75 return ( array );
76}
77
78function test() {
79 for ( tc=0; tc < testcases.length; tc++ ) {
80 testcases[tc].passed = writeTestCaseResult(
81 testcases[tc].expect,
82 testcases[tc].actual,
83 testcases[tc].description +" = "+
84 testcases[tc].actual );
85
86 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
87 }
88 stopTest();
89 return ( testcases );
90}