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.5.js 24 ECMA Section: 15.8.2.5 atan2( y, x ) 25 Description: 26 27 Author: christine@netscape.com 28 Date: 7 july 1997 29 30*/ 31 var SECTION = "15.8.2.5"; 32 var VERSION = "ECMA_1"; 33 startTest(); 34 var TITLE = "Math.atan2(x,y)"; 35 var BUGNUMBER="76111"; 36 37 writeHeaderToLog( SECTION + " "+ TITLE); 38 39 var testcases = getTestCases(); 40 test(); 41 42function getTestCases() { 43 var array = new Array(); 44 var item = 0; 45 46 array[item++] = new TestCase( SECTION, "Math.atan2.length", 2, Math.atan2.length ); 47 48 array[item++] = new TestCase( SECTION, "Math.atan2(NaN, 0)", Number.NaN, Math.atan2(Number.NaN,0) ); 49 array[item++] = new TestCase( SECTION, "Math.atan2(null, null)", 0, Math.atan2(null, null) ); 50 array[item++] = new TestCase( SECTION, "Math.atan2(void 0, void 0)", Number.NaN, Math.atan2(void 0, void 0) ); 51 array[item++] = new TestCase( SECTION, "Math.atan2()", Number.NaN, Math.atan2() ); 52 53 array[item++] = new TestCase( SECTION, "Math.atan2(0, NaN)", Number.NaN, Math.atan2(0,Number.NaN) ); 54 array[item++] = new TestCase( SECTION, "Math.atan2(1, 0)", Math.PI/2, Math.atan2(1,0) ); 55 array[item++] = new TestCase( SECTION, "Math.atan2(1,-0)", Math.PI/2, Math.atan2(1,-0) ); 56 array[item++] = new TestCase( SECTION, "Math.atan2(0,0.001)", 0, Math.atan2(0,0.001) ); 57 array[item++] = new TestCase( SECTION, "Math.atan2(0,0)", 0, Math.atan2(0,0) ); 58 array[item++] = new TestCase( SECTION, "Math.atan2(0, -0)", Math.PI, Math.atan2(0,-0) ); 59 array[item++] = new TestCase( SECTION, "Math.atan2(0, -1)", Math.PI, Math.atan2(0, -1) ); 60 61 array[item++] = new TestCase( SECTION, "Math.atan2(-0, 1)", -0, Math.atan2(-0, 1) ); 62 array[item++] = new TestCase( SECTION, "Infinity/Math.atan2(-0, 1)", -Infinity, Infinity/Math.atan2(-0,1) ); 63 64 array[item++] = new TestCase( SECTION, "Math.atan2(-0, 0)", -0, Math.atan2(-0,0) ); 65 array[item++] = new TestCase( SECTION, "Math.atan2(-0, -0)", -Math.PI, Math.atan2(-0, -0) ); 66 array[item++] = new TestCase( SECTION, "Math.atan2(-0, -1)", -Math.PI, Math.atan2(-0, -1) ); 67 array[item++] = new TestCase( SECTION, "Math.atan2(-1, 0)", -Math.PI/2, Math.atan2(-1, 0) ); 68 array[item++] = new TestCase( SECTION, "Math.atan2(-1, -0)", -Math.PI/2, Math.atan2(-1, -0) ); 69 array[item++] = new TestCase( SECTION, "Math.atan2(1, Infinity)", 0, Math.atan2(1, Number.POSITIVE_INFINITY) ); 70 array[item++] = new TestCase( SECTION, "Math.atan2(1,-Infinity)", Math.PI, Math.atan2(1, Number.NEGATIVE_INFINITY) ); 71 72 array[item++] = new TestCase( SECTION, "Math.atan2(-1, Infinity)", -0, Math.atan2(-1,Number.POSITIVE_INFINITY) ); 73 array[item++] = new TestCase( SECTION, "Infinity/Math.atan2(-1, Infinity)", -Infinity, Infinity/Math.atan2(-1,Infinity) ); 74 75 array[item++] = new TestCase( SECTION, "Math.atan2(-1,-Infinity)", -Math.PI, Math.atan2(-1,Number.NEGATIVE_INFINITY) ); 76 array[item++] = new TestCase( SECTION, "Math.atan2(Infinity, 0)", Math.PI/2, Math.atan2(Number.POSITIVE_INFINITY, 0) ); 77 array[item++] = new TestCase( SECTION, "Math.atan2(Infinity, 1)", Math.PI/2, Math.atan2(Number.POSITIVE_INFINITY, 1) ); 78 array[item++] = new TestCase( SECTION, "Math.atan2(Infinity,-1)", Math.PI/2, Math.atan2(Number.POSITIVE_INFINITY,-1) ); 79 array[item++] = new TestCase( SECTION, "Math.atan2(Infinity,-0)", Math.PI/2, Math.atan2(Number.POSITIVE_INFINITY,-0) ); 80 array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, 0)", -Math.PI/2, Math.atan2(Number.NEGATIVE_INFINITY, 0) ); 81 array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity,-0)", -Math.PI/2, Math.atan2(Number.NEGATIVE_INFINITY,-0) ); 82 array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, 1)", -Math.PI/2, Math.atan2(Number.NEGATIVE_INFINITY, 1) ); 83 array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, -1)", -Math.PI/2, Math.atan2(Number.NEGATIVE_INFINITY,-1) ); 84 array[item++] = new TestCase( SECTION, "Math.atan2(Infinity, Infinity)", Math.PI/4, Math.atan2(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY) ); 85 array[item++] = new TestCase( SECTION, "Math.atan2(Infinity, -Infinity)", 3*Math.PI/4, Math.atan2(Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY) ); 86 array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, Infinity)", -Math.PI/4, Math.atan2(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY) ); 87 array[item++] = new TestCase( SECTION, "Math.atan2(-Infinity, -Infinity)", -3*Math.PI/4, Math.atan2(Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY) ); 88 array[item++] = new TestCase( SECTION, "Math.atan2(-1, 1)", -Math.PI/4, Math.atan2( -1, 1) ); 89 90 return array; 91} 92 93function test() { 94 for ( tc=0; tc < testcases.length; tc++ ) { 95 testcases[tc].passed = writeTestCaseResult( 96 testcases[tc].expect, 97 testcases[tc].actual, 98 testcases[tc].description +" = "+ 99 testcases[tc].actual ); 100 101 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; 102 } 103 stopTest(); 104 return ( testcases ); 105} 106