Debian Codegraph @

rhino/testsrc/tests/ecma_2/Statements/dowhile-004.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 = 'dowhile-004.js';
7
8 /**
9 * File Name: dowhile-004
10 * ECMA Section:
11 * Description: do...while statements
12 *
13 * Test a labeled do...while. Break out of the loop with no label
14 * should break out of the loop, but not out of the label.
15 *
16 * Author: [email protected]
17 * Date: 11 August 1998
18 */
19 var SECTION = "dowhile-004";
20 var VERSION = "ECMA_2";
21 var TITLE = "do...while with a labeled continue statement";
22
23 startTest();
24 writeHeaderToLog( SECTION + " "+ TITLE);
25
26 DoWhile( 0, 1 );
27 DoWhile( 1, 1 );
28 DoWhile( -1, 1 );
29 DoWhile( 5, 5 );
30
31 test();
32
33 function DoWhile( limit, expect ) {
34 i = 0;
35 result1 = "pass";
36 result2 = "failed: broke out of labeled statement unexpectedly";
37
38 foo: {
39 do {
40 i++;
41 if ( ! (i < limit) ) {
42 break;
43 result1 = "fail: evaluated statement after a labeled break";
44 }
45 } while ( true );
46
47 result2 = "pass";
48 }
49
50 new TestCase(
51 SECTION,
52 "do while ( " + i +" < " + limit +" )",
53 expect,
54 i );
55
56 new TestCase(
57 SECTION,
58 "breaking out of a do... while loop",
59 "pass",
60 result1 );
61
62
63 new TestCase(
64 SECTION,
65 "breaking out of a labeled do...while loop",
66 "pass",
67 result2 );
68 }