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.1.js 24 ECMA Section: 15.8.1.js Value Properties of the Math Object 25 15.8.1.1 E 26 15.8.1.2 LN10 27 15.8.1.3 LN2 28 15.8.1.4 LOG2E 29 15.8.1.5 LOG10E 30 15.8.1.6 PI 31 15.8.1.7 SQRT1_2 32 15.8.1.8 SQRT2 33 Description: verify the values of some math constants 34 Author: christine (at) netscape.com 35 Date: 7 july 1997 36 37 */ 38 var SECTION = "15.8.1" 39 var VERSION = "ECMA_1"; 40 startTest(); 41 var TITLE = "Value Properties of the Math Object"; 42 43 writeHeaderToLog( SECTION + " "+ TITLE); 44 45 var testcases = getTestCases(); 46 test(); 47 48 function getTestCases() { 49 var array = new Array(); 50 var item = 0; 51 52 array[item++] = new TestCase( "15.8.1.1", "Math.E", 2.7182818284590452354, Math.E ); 53 array[item++] = new TestCase( "15.8.1.1", "typeof Math.E", "number", typeof Math.E ); 54 array[item++] = new TestCase( "15.8.1.2", "Math.LN10", 2.302585092994046, Math.LN10 ); 55 array[item++] = new TestCase( "15.8.1.2", "typeof Math.LN10", "number", typeof Math.LN10 ); 56 array[item++] = new TestCase( "15.8.1.3", "Math.LN2", 0.6931471805599453, Math.LN2 ); 57 array[item++] = new TestCase( "15.8.1.3", "typeof Math.LN2", "number", typeof Math.LN2 ); 58 array[item++] = new TestCase( "15.8.1.4", "Math.LOG2E", 1.4426950408889634, Math.LOG2E ); 59 array[item++] = new TestCase( "15.8.1.4", "typeof Math.LOG2E", "number", typeof Math.LOG2E ); 60 array[item++] = new TestCase( "15.8.1.5", "Math.LOG10E", 0.4342944819032518, Math.LOG10E); 61 array[item++] = new TestCase( "15.8.1.5", "typeof Math.LOG10E", "number", typeof Math.LOG10E); 62 array[item++] = new TestCase( "15.8.1.6", "Math.PI", 3.14159265358979323846, Math.PI ); 63 array[item++] = new TestCase( "15.8.1.6", "typeof Math.PI", "number", typeof Math.PI ); 64 array[item++] = new TestCase( "15.8.1.7", "Math.SQRT1_2", 0.7071067811865476, Math.SQRT1_2); 65 array[item++] = new TestCase( "15.8.1.7", "typeof Math.SQRT1_2", "number", typeof Math.SQRT1_2); 66 array[item++] = new TestCase( "15.8.1.8", "Math.SQRT2", 1.4142135623730951, Math.SQRT2 ); 67 array[item++] = new TestCase( "15.8.1.8", "typeof Math.SQRT2", "number", typeof Math.SQRT2 ); 68 69 array[item++] = new TestCase( SECTION, "var MATHPROPS='';for( p in Math ){ MATHPROPS +=p; };MATHPROPS", 70 "", 71 eval("var MATHPROPS='';for( p in Math ){ MATHPROPS +=p; };MATHPROPS") ); 72 73 return ( array ); 74 } 75 76 function test() { 77 for ( i = 0; i < testcases.length; i++ ) { 78 testcases[i].passed = writeTestCaseResult( 79 testcases[i].expect, 80 testcases[i].actual, 81 testcases[i].description +" = "+ testcases[i].actual ); 82 testcases[i].reason += ( testcases[i].passed ) ? "" : "wrong value " 83 } 84 stopTest(); 85 return ( testcases ); 86 } 87