Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / tests / js1_2 / statements / continue.js
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  * http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * The Original Code is Mozilla Communicator client code, released
16  * March 31, 1998.
17  *
18  * The Initial Developer of the Original Code is
19  * Netscape Communications Corporation.
20  * Portions created by the Initial Developer are Copyright (C) 1998
21  * the Initial Developer. All Rights Reserved.
22  *
23  * Contributor(s):
24  *
25  * Alternatively, the contents of this file may be used under the terms of
26  * either the GNU General Public License Version 2 or later (the "GPL"), or
27  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28  * in which case the provisions of the GPL or the LGPL are applicable instead
29  * of those above. If you wish to allow use of your version of this file only
30  * under the terms of either the GPL or the LGPL, and not to allow others to
31  * use your version of this file under the terms of the MPL, indicate your
32  * decision by deleting the provisions above and replace them with the notice
33  * and other provisions required by the GPL or the LGPL. If you do not delete
34  * the provisions above, a recipient may use your version of this file under
35  * the terms of any one of the MPL, the GPL or the LGPL.
36  *
37  * ***** END LICENSE BLOCK ***** */
38
39
40 /**
41    Filename:     continue.js
42    Description:  'Tests the continue statement'
43
44    Author:       Nick Lerissa
45    Date:         March 18, 1998
46 */
47
48 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
49 var VERSION = 'no version';
50 startTest();
51 var TITLE   = 'statements: continue';
52
53 writeHeaderToLog("Executing script: continue.js");
54 writeHeaderToLog( SECTION + " "+ TITLE);
55
56 var i,j;
57
58 j = 0;
59 for (i = 0; i < 200; i++)
60 {
61   if (i == 100)
62     continue;
63   j++;
64 }
65
66 // '"continue" in a "for" loop'
67 new TestCase ( SECTION, '"continue" in "for" loop',
68                199, j);
69
70
71 j = 0;
72 out1:
73 for (i = 0; i < 1000; i++)
74 {
75   if (i == 100)
76   {
77   out2:
78     for (var k = 0; k < 1000; k++)
79     {
80       if (k == 500) continue out1;
81     }
82     j = 3000;
83   }
84   j++;
85 }
86
87 // '"continue" in a "for" loop with a "label"'
88 new TestCase ( SECTION, '"continue" in "for" loop with a "label"',
89                999, j);
90
91 i = 0;
92 j = 1;
93
94 while (i != j)
95 {
96   i++;
97   if (i == 100) continue;
98   j++;
99 }
100
101 // '"continue" in a "while" loop'
102 new TestCase ( SECTION, '"continue" in a "while" loop',
103                100, j );
104
105 j = 0;
106 i = 0;
107 out3:
108 while (i < 1000)
109 {
110   if (i == 100)
111   {
112     var k = 0;
113   out4:
114     while (k < 1000)
115     {
116       if (k == 500)
117       {
118         i++;
119         continue out3;
120       }
121       k++;
122     }
123     j = 3000;
124   }
125   j++;
126   i++;
127 }
128
129 // '"continue" in a "while" loop with a "label"'
130 new TestCase ( SECTION, '"continue" in a "while" loop with a "label"',
131                999, j);
132
133 i = 0;
134 j = 1;
135
136 do
137 {
138   i++;
139   if (i == 100) continue;
140   j++;
141 } while (i != j);
142
143
144 // '"continue" in a "do" loop'
145 new TestCase ( SECTION, '"continue" in a "do" loop',
146                100, j );
147
148 j = 0;
149 i = 0;
150 out5:
151 do
152 {
153   if (i == 100)
154   {
155     var k = 0;
156   out6:
157     do
158     {
159       if (k == 500)
160       {
161         i++;
162         continue out5;
163       }
164       k++;
165     }while (k < 1000);
166     j = 3000;
167   }
168   j++;
169   i++;
170 }while (i < 1000);
171
172 // '"continue" in a "do" loop with a "label"'
173 new TestCase ( SECTION, '"continue" in a "do" loop with a "label"',
174                999, j);
175
176 test();