|
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: label-001.js |
|
9 * ECMA Section: |
|
10 * Description: Labeled statements |
|
11 * |
|
12 * Labeled break and continue within a for loop. |
|
13 * |
|
14 * |
|
15 * Author: christine@netscape.com |
|
16 * Date: 11 August 1998 |
|
17 */ |
|
18 var SECTION = "label-003"; |
|
19 var VERSION = "ECMA_2"; |
|
20 var TITLE = "Labeled statements"; |
|
21 |
|
22 startTest(); |
|
23 writeHeaderToLog( SECTION + " "+ TITLE); |
|
24 |
|
25 LabelTest(0, 0); |
|
26 LabelTest(1, 1) |
|
27 LabelTest(-1, 1000); |
|
28 LabelTest(false, 0); |
|
29 LabelTest(true, 1); |
|
30 |
|
31 test(); |
|
32 |
|
33 function LabelTest( limit, expect) { |
|
34 woo: for ( var result = 0; result < 1000; result++ ) { if (result == limit) { break woo; } else { continue woo; } }; |
|
35 |
|
36 new TestCase( |
|
37 SECTION, |
|
38 "break out of a labeled for loop: "+ limit, |
|
39 expect, |
|
40 result ); |
|
41 } |
|
42 |