Debian Codegraph @

rhino/testsrc/tests/ecma_2/Statements/while-003.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 gTestfile = 'while-003.js';
7
8 /**
9 * File Name: while-003
10 * ECMA Section:
11 * Description: while statement
12 *
13 * The while expression evaluates to true, Statement returns abrupt completion.
14 *
15 * Author: [email protected]
16 * Date: 11 August 1998
17 */
18 var SECTION = "while-003";
19 var VERSION = "ECMA_2";
20 var TITLE = "while statement";
21
22 startTest();
23 writeHeaderToLog( SECTION + " "+ TITLE);
24
25 DoWhile( new DoWhileObject(
26 "while expression is true",
27 true,
28 "result = \"pass\";" ));
29
30 DoWhile( new DoWhileObject(
31 "while expression is 1",
32 1,
33 "result = \"pass\";" ));
34
35 DoWhile( new DoWhileObject(
36 "while expression is new Boolean(false)",
37 new Boolean(false),
38 "result = \"pass\";" ));
39
40 DoWhile( new DoWhileObject(
41 "while expression is new Object()",
42 new Object(),
43 "result = \"pass\";" ));
44
45 DoWhile( new DoWhileObject(
46 "while expression is \"hi\"",
47 "hi",
48 "result = \"pass\";" ));
49 /*
50 DoWhile( new DoWhileObject(
51 "while expression has a continue in it",
52 "true",
53 "if ( i == void 0 ) i = 0; result=\"pass\"; if ( ++i == 1 ) {continue;} else {break;} result=\"fail\";"
54 ));
55 */
56 test();
57
58 function DoWhileObject( d, e, s ) {
59 this.description = d;
60 this.whileExpression = e;
61 this.statements = s;
62 }
63
64 function DoWhile( object ) {
65 result = "fail: statements in while block were not evaluated";
66
67 while ( expression = object.whileExpression ) {
68 eval( object.statements );
69 break;
70 }
71
72 // verify that the while expression was evaluated
73
74 new TestCase(
75 SECTION,
76 "verify that while expression was evaluated (should be "+
77 object.whileExpression +")",
78 "pass",
79 (object.whileExpression == expression ||
80 ( isNaN(object.whileExpression) && isNaN(expression) )
81 ) ? "pass" : "fail" );
82
83 new TestCase(
84 SECTION,
85 object.description,
86 "pass",
87 result );
88 }