9 var GLOBAL = "[object global]";
10 var PASSED = " PASSED!"
11 var FAILED = " FAILED! expected: ";
14 for ( tc=0; tc < testcases.length; tc++ ) {
15 testcases[tc].passed = writeTestCaseResult(
18 testcases[tc].description +" = "+
19 testcases[tc].actual );
21 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
26 /* wrapper for test cas constructor that doesn't require the SECTION
30 function AddTestCase( description, expect, actual ) {
31 testcases[tc++] = new TestCase( SECTION, description, expect, actual );
34 function TestCase( n, d, e, a ) {
42 this.passed = getTestCaseResult( this.expect, this.actual );
44 function startTest() {
46 // JavaScript 1.3 is supposed to be compliant ecma version 1.0
47 if ( VERSION == "ECMA_1" ) {
50 if ( VERSION == "JS_1.3" ) {
53 if ( VERSION == "JS_1.2" ) {
56 if ( VERSION == "JS_1.1" ) {
59 // for ecma version 2.0, we will leave the javascript version to
60 // the default ( for now ).
64 writeLineToLog ("BUGNUMBER: " + BUGNUMBER );
67 testcases = new Array();
70 function getTestCaseResult( expect, actual ) {
71 // because ( NaN == NaN ) always returns false, need to do
72 // a special compare to see if we got the right result.
73 if ( actual != actual ) {
74 if ( typeof actual == "object" ) {
75 actual = "NaN object";
77 actual = "NaN number";
80 if ( expect != expect ) {
81 if ( typeof expect == "object" ) {
82 expect = "NaN object";
84 expect = "NaN number";
88 var passed = ( expect == actual ) ? true : false;
90 // if both objects are numbers, give a little leeway for rounding.
92 && typeof(actual) == "number"
93 && typeof(expect) == "number"
95 if ( Math.abs(actual-expect) < 0.0000001 ) {
100 // verify type is the same
101 if ( typeof(expect) != typeof(actual) ) {
108 * Begin printing functions. These functions use the shell's
109 * print function. When running tests in the browser, these
110 * functions, override these functions with functions that use
114 function writeTestCaseResult( expect, actual, string ) {
115 var passed = getTestCaseResult( expect, actual );
116 writeFormattedResult( expect, actual, string, passed );
119 function writeFormattedResult( expect, actual, string, passed ) {
121 s += ( passed ) ? PASSED : FAILED + expect;
125 function writeLineToLog( string ) {
128 function writeHeaderToLog( string ) {
131 /* end of print functions */
133 function stopTest() {
135 if ( gc != undefined ) {