]>
Commit | Line | Data |
---|---|---|
1 | /* The contents of this file are subject to the Netscape Public | |
2 | * License Version 1.1 (the "License"); you may not use this file | |
3 | * except in compliance with the License. You may obtain a copy of | |
4 | * the License at http://www.mozilla.org/NPL/ | |
5 | * | |
6 | * Software distributed under the License is distributed on an "AS | |
7 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or | |
8 | * implied. See the License for the specific language governing | |
9 | * rights and limitations under the License. | |
10 | * | |
11 | * The Original Code is Mozilla Communicator client code, released March | |
12 | * 31, 1998. | |
13 | * | |
14 | * The Initial Developer of the Original Code is Netscape Communications | |
15 | * Corporation. Portions created by Netscape are | |
16 | * Copyright (C) 1998 Netscape Communications Corporation. All | |
17 | * Rights Reserved. | |
18 | * | |
19 | * Contributor(s): | |
20 | * | |
21 | */ | |
22 | /** | |
23 | Filename: continue.js | |
24 | Description: 'Tests the continue statement' | |
25 | ||
26 | Author: Nick Lerissa | |
27 | Date: March 18, 1998 | |
28 | */ | |
29 | ||
30 | var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; | |
31 | var VERSION = 'no version'; | |
32 | startTest(); | |
33 | var TITLE = 'statements: continue'; | |
34 | ||
35 | writeHeaderToLog("Executing script: continue.js"); | |
36 | writeHeaderToLog( SECTION + " "+ TITLE); | |
37 | ||
38 | var count = 0; | |
39 | var testcases = new Array(); | |
40 | ||
41 | var i,j; | |
42 | ||
43 | j = 0; | |
44 | for (i = 0; i < 200; i++) | |
45 | { | |
46 | if (i == 100) | |
47 | continue; | |
48 | j++; | |
49 | } | |
50 | ||
51 | // '"continue" in a "for" loop' | |
52 | testcases[count++] = new TestCase ( SECTION, '"continue" in "for" loop', | |
53 | 199, j); | |
54 | ||
55 | ||
56 | j = 0; | |
57 | out1: | |
58 | for (i = 0; i < 1000; i++) | |
59 | { | |
60 | if (i == 100) | |
61 | { | |
62 | out2: | |
63 | for (var k = 0; k < 1000; k++) | |
64 | { | |
65 | if (k == 500) continue out1; | |
66 | } | |
67 | j = 3000; | |
68 | } | |
69 | j++; | |
70 | } | |
71 | ||
72 | // '"continue" in a "for" loop with a "label"' | |
73 | testcases[count++] = new TestCase ( SECTION, '"continue" in "for" loop with a "label"', | |
74 | 999, j); | |
75 | ||
76 | i = 0; | |
77 | j = 1; | |
78 | ||
79 | while (i != j) | |
80 | { | |
81 | i++; | |
82 | if (i == 100) continue; | |
83 | j++; | |
84 | } | |
85 | ||
86 | // '"continue" in a "while" loop' | |
87 | testcases[count++] = new TestCase ( SECTION, '"continue" in a "while" loop', | |
88 | 100, j ); | |
89 | ||
90 | j = 0; | |
91 | i = 0; | |
92 | out3: | |
93 | while (i < 1000) | |
94 | { | |
95 | if (i == 100) | |
96 | { | |
97 | var k = 0; | |
98 | out4: | |
99 | while (k < 1000) | |
100 | { | |
101 | if (k == 500) | |
102 | { | |
103 | i++; | |
104 | continue out3; | |
105 | } | |
106 | k++; | |
107 | } | |
108 | j = 3000; | |
109 | } | |
110 | j++; | |
111 | i++; | |
112 | } | |
113 | ||
114 | // '"continue" in a "while" loop with a "label"' | |
115 | testcases[count++] = new TestCase ( SECTION, '"continue" in a "while" loop with a "label"', | |
116 | 999, j); | |
117 | ||
118 | i = 0; | |
119 | j = 1; | |
120 | ||
121 | do | |
122 | { | |
123 | i++; | |
124 | if (i == 100) continue; | |
125 | j++; | |
126 | } while (i != j); | |
127 | ||
128 | ||
129 | // '"continue" in a "do" loop' | |
130 | testcases[count++] = new TestCase ( SECTION, '"continue" in a "do" loop', | |
131 | 100, j ); | |
132 | ||
133 | j = 0; | |
134 | i = 0; | |
135 | out5: | |
136 | do | |
137 | { | |
138 | if (i == 100) | |
139 | { | |
140 | var k = 0; | |
141 | out6: | |
142 | do | |
143 | { | |
144 | if (k == 500) | |
145 | { | |
146 | i++; | |
147 | continue out5; | |
148 | } | |
149 | k++; | |
150 | }while (k < 1000); | |
151 | j = 3000; | |
152 | } | |
153 | j++; | |
154 | i++; | |
155 | }while (i < 1000); | |
156 | ||
157 | // '"continue" in a "do" loop with a "label"' | |
158 | testcases[count++] = new TestCase ( SECTION, '"continue" in a "do" loop with a "label"', | |
159 | 999, j); | |
160 | ||
161 | function test() | |
162 | { | |
163 | for ( tc=0; tc < testcases.length; tc++ ) { | |
164 | testcases[tc].passed = writeTestCaseResult( | |
165 | testcases[tc].expect, | |
166 | testcases[tc].actual, | |
167 | testcases[tc].description +" = "+ | |
168 | testcases[tc].actual ); | |
169 | testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; | |
170 | } | |
171 | stopTest(); | |
172 | return ( testcases ); | |
173 | } | |
174 | ||
175 | test(); |