]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_2/Statements/while-002.js
4 * Description: while statement
6 * Verify that the while statement is not executed if the while expression is
9 * Author: christine@netscape.com
10 * Date: 11 August 1998
12 var SECTION
= "while-002";
13 var VERSION
= "ECMA_2";
14 var TITLE
= "while statement";
17 writeHeaderToLog( SECTION
+ " "+ TITLE
);
20 var testcases
= new Array();
22 DoWhile( new DoWhileObject(
23 "while expression is null",
25 "result = \"fail: should not have evaluated statements in while block;break"
28 DoWhile( new DoWhileObject(
29 "while expression is undefined",
31 "result = \"fail: should not have evaluated statements in while block; break"
34 DoWhile( new DoWhileObject(
35 "while expression is 0",
37 "result = \"fail: should not have evaluated statements in while block; break;"
40 DoWhile( new DoWhileObject(
41 "while expression is eval(\"\")",
43 "result = \"fail: should not have evaluated statements in while block; break"
46 DoWhile( new DoWhileObject(
47 "while expression is NaN",
49 "result = \"fail: should not have evaluated statements in while block; break"
54 function DoWhileObject( d
, e
, s
) {
56 this.whileExpression
= e
;
60 function DoWhile( object
) {
63 while ( expression
= object
.whileExpression
) {
64 eval( object
.statements
);
67 // verify that the while expression was evaluated
69 testcases
[tc
++] = new TestCase(
71 "verify that while expression was evaluated (should be "+
72 object
.whileExpression
+")",
74 (object
.whileExpression
== expression
||
75 ( isNaN(object
.whileExpression
) && isNaN(expression
) )
76 ) ? "pass" : "fail" );
78 testcases
[tc
++] = new TestCase(