]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_1/jsref.js
22 var PASSED
= " PASSED!"
23 var FAILED
= " FAILED! expected: ";
28 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
29 testcases
[tc
].passed
= writeTestCaseResult(
32 testcases
[tc
].description
+" = "+
33 testcases
[tc
].actual
);
35 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
41 function TestCase( n
, d
, e
, a
) {
48 this.bugnumber
= BUGNUMBER
;
50 this.passed
= getTestCaseResult( this.expect
, this.actual
);
52 function startTest() {
54 // JavaScript 1.3 is supposed to be compliant ecma version 1.0
55 if ( VERSION == "ECMA_1" ) {
58 if ( VERSION == "JS_1.3" ) {
61 if ( VERSION == "JS_1.2" ) {
64 if ( VERSION == "JS_1.1" ) {
67 // for ecma version 2.0, we will leave the javascript version to
68 // the default ( for now ).
71 function getTestCaseResult( expect
, actual
) {
72 // because ( NaN == NaN ) always returns false, need to do
73 // a special compare to see if we got the right result.
74 if ( actual
!= actual
) {
75 if ( typeof actual
== "object" ) {
76 actual
= "NaN object";
78 actual
= "NaN number";
81 if ( expect
!= expect
) {
82 if ( typeof expect
== "object" ) {
83 expect
= "NaN object";
85 expect
= "NaN number";
89 var passed
= ( expect
== actual
) ? true : false;
91 // if both objects are numbers, give a little leeway for rounding.
93 && typeof(actual
) == "number"
94 && typeof(expect
) == "number"
96 if ( Math
.abs(actual
-expect
) < 0.0000001 ) {
101 // verify type is the same
102 if ( typeof(expect
) != typeof(actual
) ) {
108 function writeTestCaseResult( expect
, actual
, string
) {
109 var passed
= getTestCaseResult( expect
, actual
);
110 writeFormattedResult( expect
, actual
, string
, passed
);
113 function writeFormattedResult( expect
, actual
, string
, passed
) {
114 var s
= TT
+ string
;
117 k
< (60 - string
.length
>= 0 ? 60 - string
.length : 5) ;
123 s
+= ( passed
) ? FONT_GREEN
+ NBSP
+ PASSED : FONT_RED
+ NBSP
+ FAILED
+ expect
+ TT_
;
125 writeLineToLog( s
+ FONT_
+ B_
+ TT_
);
130 function writeLineToLog( string
) {
131 print( string
+ BR
+ CR
);
133 function writeHeaderToLog( string
) {
134 print( H2
+ string
+ H2_
);
136 function stopTest() {
137 var sizeTag
= "<#TEST CASES SIZE>";
138 var doneTag
= "<#TEST CASES DONE>";
139 var beginTag
= "<#TEST CASE ";
143 print(testcases
.length
);
144 for (tc
= 0; tc
< testcases
.length
; tc
++)
146 print(beginTag
+ 'PASSED' + endTag
);
147 print(testcases
[tc
].passed
);
148 print(beginTag
+ 'NAME' + endTag
);
149 print(testcases
[tc
].name
);
150 print(beginTag
+ 'EXPECTED' + endTag
);
151 print(testcases
[tc
].expect
);
152 print(beginTag
+ 'ACTUAL' + endTag
);
153 print(testcases
[tc
].actual
);
154 print(beginTag
+ 'DESCRIPTION' + endTag
);
155 print(testcases
[tc
].description
);
156 print(beginTag
+ 'REASON' + endTag
);
157 print(( testcases
[tc
].passed
) ? "" : "wrong value ");
158 print(beginTag
+ 'BUGNUMBER' + endTag
);
164 function getFailedCases() {
165 for ( var i
= 0; i
< testcases
.length
; i
++ ) {
166 if ( ! testcases
[i
].passed
) {
167 print( testcases
[i
].description
+" = " +testcases
[i
].actual
+" expected: "+ testcases
[i
].expect
);