Debian Codegraph @

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