]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_1/shell.js
2 * The contents of this file are subject to the Netscape Public
3 * License Version 1.1 (the "License"); you may not use this file
4 * except in compliance with the License. You may obtain a copy of
5 * the License at http://www.mozilla.org/NPL/
7 * Software distributed under the License is distributed on an "AS
8 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9 * implied. See the License for the specific language governing
10 * rights and limitations under the License.
12 * The Original Code is mozilla.org code.
14 * The Initial Developer of the Original Code is Netscape
15 * Communications Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
22 var completed
= false;
30 var GLOBAL
= "[object global]";
31 var PASSED
= " PASSED!"
32 var FAILED
= " FAILED! expected: ";
35 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
36 testcases
[tc
].passed
= writeTestCaseResult(
39 testcases
[tc
].description
+" = "+
40 testcases
[tc
].actual
);
42 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
47 /* wrapper for test cas constructor that doesn't require the SECTION
51 function AddTestCase( description
, expect
, actual
) {
52 testcases
[tc
++] = new TestCase( SECTION
, description
, expect
, actual
);
55 function TestCase( n
, d
, e
, a
) {
63 this.passed
= getTestCaseResult( this.expect
, this.actual
);
65 function startTest() {
69 writeLineToLog ("BUGNUMBER: " + BUGNUMBER
);
72 testcases
= new Array();
75 function getTestCaseResult( expect
, actual
) {
76 // because ( NaN == NaN ) always returns false, need to do
77 // a special compare to see if we got the right result.
78 if ( actual
!= actual
) {
79 if ( typeof actual
== "object" ) {
80 actual
= "NaN object";
82 actual
= "NaN number";
85 if ( expect
!= expect
) {
86 if ( typeof expect
== "object" ) {
87 expect
= "NaN object";
89 expect
= "NaN number";
93 var passed
= ( expect
== actual
) ? true : false;
95 // if both objects are numbers, give a little leeway for rounding.
97 && typeof(actual
) == "number"
98 && typeof(expect
) == "number"
100 if ( Math
.abs(actual
-expect
) < 0.0000001 ) {
105 // verify type is the same
106 if ( typeof(expect
) != typeof(actual
) ) {
113 * Begin printing functions. These functions use the shell's
114 * print function. When running tests in the browser, these
115 * functions, override these functions with functions that use
119 function writeTestCaseResult( expect
, actual
, string
) {
120 var passed
= getTestCaseResult( expect
, actual
);
121 writeFormattedResult( expect
, actual
, string
, passed
);
124 function writeFormattedResult( expect
, actual
, string
, passed
) {
126 s
+= ( passed
) ? PASSED : FAILED
+ expect
;
130 function writeLineToLog( string
) {
133 function writeHeaderToLog( string
) {
136 /* end of print functions */
138 function stopTest() {
140 if ( gc
!= undefined ) {