michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: File Name: 15.8.2.7.js michael@0: ECMA Section: 15.8.2.7 cos( x ) michael@0: Description: return an approximation to the cosine of the michael@0: argument. argument is expressed in radians michael@0: Author: christine@netscape.com michael@0: Date: 7 july 1997 michael@0: michael@0: */ michael@0: michael@0: var SECTION = "15.8.2.7"; michael@0: var VERSION = "ECMA_1"; michael@0: startTest(); michael@0: var TITLE = "Math.cos(x)"; michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos.length", michael@0: 1, michael@0: Math.cos.length ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos()", michael@0: Number.NaN, michael@0: Math.cos() ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(void 0)", michael@0: Number.NaN, michael@0: Math.cos(void 0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(false)", michael@0: 1, michael@0: Math.cos(false) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(null)", michael@0: 1, michael@0: Math.cos(null) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos('0')", michael@0: 1, michael@0: Math.cos('0') ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos('Infinity')", michael@0: Number.NaN, michael@0: Math.cos("Infinity") ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos('3.14159265359')", michael@0: -1, michael@0: Math.cos('3.14159265359') ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(NaN)", michael@0: Number.NaN, michael@0: Math.cos(Number.NaN) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(0)", michael@0: 1, michael@0: Math.cos(0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-0)", michael@0: 1, michael@0: Math.cos(-0) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(Infinity)", michael@0: Number.NaN, michael@0: Math.cos(Number.POSITIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-Infinity)", michael@0: Number.NaN, michael@0: Math.cos(Number.NEGATIVE_INFINITY) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(0.7853981633974)", michael@0: 0.7071067811865, michael@0: Math.cos(0.7853981633974) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(1.570796326795)", michael@0: 0, michael@0: Math.cos(1.570796326795) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(2.356194490192)", michael@0: -0.7071067811865, michael@0: Math.cos(2.356194490192) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(3.14159265359)", michael@0: -1, michael@0: Math.cos(3.14159265359) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(3.926990816987)", michael@0: -0.7071067811865, michael@0: Math.cos(3.926990816987) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(4.712388980385)", michael@0: 0, michael@0: Math.cos(4.712388980385) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(5.497787143782)", michael@0: 0.7071067811865, michael@0: Math.cos(5.497787143782) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(Math.PI*2)", michael@0: 1, michael@0: Math.cos(Math.PI*2) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(Math.PI/4)", michael@0: Math.SQRT2/2, michael@0: Math.cos(Math.PI/4) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(Math.PI/2)", michael@0: 0, michael@0: Math.cos(Math.PI/2) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(3*Math.PI/4)", michael@0: -Math.SQRT2/2, michael@0: Math.cos(3*Math.PI/4) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(Math.PI)", michael@0: -1, michael@0: Math.cos(Math.PI) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(5*Math.PI/4)", michael@0: -Math.SQRT2/2, michael@0: Math.cos(5*Math.PI/4) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(3*Math.PI/2)", michael@0: 0, michael@0: Math.cos(3*Math.PI/2) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(7*Math.PI/4)", michael@0: Math.SQRT2/2, michael@0: Math.cos(7*Math.PI/4) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(Math.PI*2)", michael@0: 1, michael@0: Math.cos(2*Math.PI) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-0.7853981633974)", michael@0: 0.7071067811865, michael@0: Math.cos(-0.7853981633974) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-1.570796326795)", michael@0: 0, michael@0: Math.cos(-1.570796326795) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-2.3561944901920)", michael@0: -.7071067811865, michael@0: Math.cos(2.3561944901920) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-3.14159265359)", michael@0: -1, michael@0: Math.cos(3.14159265359) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-3.926990816987)", michael@0: -0.7071067811865, michael@0: Math.cos(3.926990816987) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-4.712388980385)", michael@0: 0, michael@0: Math.cos(4.712388980385) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-5.497787143782)", michael@0: 0.7071067811865, michael@0: Math.cos(5.497787143782) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-6.28318530718)", michael@0: 1, michael@0: Math.cos(6.28318530718) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-Math.PI/4)", michael@0: Math.SQRT2/2, michael@0: Math.cos(-Math.PI/4) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-Math.PI/2)", michael@0: 0, michael@0: Math.cos(-Math.PI/2) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-3*Math.PI/4)", michael@0: -Math.SQRT2/2, michael@0: Math.cos(-3*Math.PI/4) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-Math.PI)", michael@0: -1, michael@0: Math.cos(-Math.PI) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-5*Math.PI/4)", michael@0: -Math.SQRT2/2, michael@0: Math.cos(-5*Math.PI/4) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-3*Math.PI/2)", michael@0: 0, michael@0: Math.cos(-3*Math.PI/2) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-7*Math.PI/4)", michael@0: Math.SQRT2/2, michael@0: Math.cos(-7*Math.PI/4) ); michael@0: michael@0: new TestCase( SECTION, michael@0: "Math.cos(-Math.PI*2)", michael@0: 1, michael@0: Math.cos(-Math.PI*2) ); michael@0: michael@0: test();