|
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 |
|
7 /** |
|
8 * File Name: dowhile-005 |
|
9 * ECMA Section: |
|
10 * Description: do...while statements |
|
11 * |
|
12 * Test a labeled do...while. Break out of the loop with no label |
|
13 * should break out of the loop, but not out of the label. |
|
14 * |
|
15 * Currently causes an infinite loop in the monkey. Uncomment the |
|
16 * print statement below and it works OK. |
|
17 * |
|
18 * Author: christine@netscape.com |
|
19 * Date: 26 August 1998 |
|
20 */ |
|
21 var SECTION = "dowhile-005"; |
|
22 var VERSION = "ECMA_2"; |
|
23 var TITLE = "do...while with a labeled continue statement"; |
|
24 var BUGNUMBER = "316293"; |
|
25 |
|
26 startTest(); |
|
27 writeHeaderToLog( SECTION + " "+ TITLE); |
|
28 |
|
29 NestedLabel(); |
|
30 |
|
31 |
|
32 test(); |
|
33 |
|
34 function NestedLabel() { |
|
35 i = 0; |
|
36 result1 = "pass"; |
|
37 result2 = "fail: did not hit code after inner loop"; |
|
38 result3 = "pass"; |
|
39 |
|
40 outer: { |
|
41 do { |
|
42 inner: { |
|
43 // print( i ); |
|
44 break inner; |
|
45 result1 = "fail: did break out of inner label"; |
|
46 } |
|
47 result2 = "pass"; |
|
48 break outer; |
|
49 print(i); |
|
50 } while ( i++ < 100 ); |
|
51 |
|
52 } |
|
53 |
|
54 result3 = "fail: did not break out of outer label"; |
|
55 |
|
56 new TestCase( |
|
57 SECTION, |
|
58 "number of loop iterations", |
|
59 0, |
|
60 i ); |
|
61 |
|
62 new TestCase( |
|
63 SECTION, |
|
64 "break out of inner loop", |
|
65 "pass", |
|
66 result1 ); |
|
67 |
|
68 new TestCase( |
|
69 SECTION, |
|
70 "break out of outer loop", |
|
71 "pass", |
|
72 result2 ); |
|
73 } |