Debian Codegraph @

rhino/testsrc/tests/js1_2/statements/break.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 = 'break.js';
7
8 /**
9 Filename: break.js
10 Description: 'Tests the break statement'
11
12 Author: Nick Lerissa
13 Date: March 18, 1998
14 */
15
16 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
17 var VERSION = 'no version';
18 startTest();
19 var TITLE = 'statements: break';
20
21 writeHeaderToLog("Executing script: break.js");
22 writeHeaderToLog( SECTION + " "+ TITLE);
23
24 var i,j;
25
26 for (i = 0; i < 1000; i++)
27 {
28 if (i == 100) break;
29 }
30
31 // 'breaking out of "for" loop'
32 new TestCase ( SECTION, 'breaking out of "for" loop',
33 100, i);
34
35 j = 2000;
36
37 out1:
38 for (i = 0; i < 1000; i++)
39 {
40 if (i == 100)
41 {
42 out2:
43 for (j = 0; j < 1000; j++)
44 {
45 if (j == 500) break out1;
46 }
47 j = 2001;
48 }
49 j = 2002;
50 }
51
52 // 'breaking out of a "for" loop with a "label"'
53 new TestCase ( SECTION, 'breaking out of a "for" loop with a "label"',
54 500, j);
55
56 i = 0;
57
58 while (i < 1000)
59 {
60 if (i == 100) break;
61 i++;
62 }
63
64 // 'breaking out of a "while" loop'
65 new TestCase ( SECTION, 'breaking out of a "while" loop',
66 100, i );
67
68
69 j = 2000;
70 i = 0;
71
72 out3:
73 while (i < 1000)
74 {
75 if (i == 100)
76 {
77 j = 0;
78 out4:
79 while (j < 1000)
80 {
81 if (j == 500) break out3;
82 j++;
83 }
84 j = 2001;
85 }
86 j = 2002;
87 i++;
88 }
89
90 // 'breaking out of a "while" loop with a "label"'
91 new TestCase ( SECTION, 'breaking out of a "while" loop with a "label"',
92 500, j);
93
94 i = 0;
95
96 do
97 {
98 if (i == 100) break;
99 i++;
100 } while (i < 1000);
101
102 // 'breaking out of a "do" loop'
103 new TestCase ( SECTION, 'breaking out of a "do" loop',
104 100, i );
105
106 j = 2000;
107 i = 0;
108
109 out5:
110 do
111 {
112 if (i == 100)
113 {
114 j = 0;
115 out6:
116 do
117 {
118 if (j == 500) break out5;
119 j++;
120 }while (j < 1000);
121 j = 2001;
122 }
123 j = 2002;
124 i++;
125 }while (i < 1000);
126
127 // 'breaking out of a "do" loop with a "label"'
128 new TestCase ( SECTION, 'breaking out of a "do" loop with a "label"',
129 500, j);
130
131 test();