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
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/
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
15 * The Original Code is JavaScript Engine testing utilities.
17 * The Initial Developer of the Original Code is
18 * Netscape Communication Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
40 * File Name: while-004
42 * Description: while statement
44 * Author: christine@netscape.com
45 * Date: 11 August 1998
47 var SECTION = "while-004";
48 var VERSION = "ECMA_2";
49 var TITLE = "while statement";
50 var BUGNUMBER="316725";
53 writeHeaderToLog( SECTION + " "+ TITLE);
64 * Break out of a while by calling return.
66 * Tests: 12.6.2 step 6.
73 result = "fail: hit code after return statement";
78 function DoWhile_1() {
79 description = "return statement in a while block";
85 "DoWhile_1" + description,
91 * While with a labeled continue statement. Verify that statements
92 * after the continue statement are not evaluated.
94 * Tests: 12.6.2 step 8.
97 function DoWhile_2() {
98 var description = "while with a labeled continue statement";
100 var result2 = "fail: did not execute code after loop, but inside label";
108 result1 = "failed: hit code after continue statement";
114 "DoWhile_2: " +description + " - code inside the loop, before the continue should be executed ("+j+")",
120 "DoWhile_2: " +description +" - code after labeled continue should not be executed",
126 "DoWhile_2: " +description +" - code after loop but inside label should be executed",
132 * While with a labeled break.
135 function DoWhile_3() {
136 var description = "while with a labeled break statement";
137 var result1 = "pass";
138 var result2 = "pass";
139 var result3 = "fail: did not get to code after label";
144 result1 = "fail: got to code after a break";
146 result2 = "fail: got to code outside of loop but inside label";
153 "DoWhile_3: " +description +" - verify break out of loop",
160 "DoWhile_3: " +description +" - verify break out of label",
166 "DoWhile_3: " +description + " - verify correct exit from label",
173 * Labled while with an unlabeled break
176 function DoWhile_4() {
177 var description = "labeled while with an unlabeled break";
178 var result1 = "pass";
179 var result2 = "pass";
180 var result3 = "fail: did not evaluate statement after label";
185 result1 = "fail: got to code after the break";
187 result2 = "fail: broke out of while, but not out of label";
193 "DoWhile_4: " +description +" - verify break out of while loop",
199 "DoWhile_4: " +description + " - verify break out of label",
205 "DoWhile_4: " +description +" - verify that statements after label are evaluated",
211 * in this case, should behave the same way as
215 function DoWhile_5() {
216 var description = "while with a labeled continue statement";
217 var result1 = "pass";
218 var result2 = "fail: did not execute code after loop, but inside label";
226 result1 = "failed: hit code after continue statement";
233 "DoWhile_5: " +description + " - continue should not execute statements above the loop",
239 "DoWhile_5: " +description +" - code after labeled continue should not be executed",
245 "DoWhile_5: " +description +" - code after loop but inside label should be executed",