michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: Filename: continue.js michael@0: Description: 'Tests the continue statement' michael@0: michael@0: Author: Nick Lerissa michael@0: Date: March 18, 1998 michael@0: */ michael@0: michael@0: var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"'; michael@0: var VERSION = 'no version'; michael@0: startTest(); michael@0: var TITLE = 'statements: continue'; michael@0: michael@0: writeHeaderToLog("Executing script: continue.js"); michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: var i,j; michael@0: michael@0: j = 0; michael@0: for (i = 0; i < 200; i++) michael@0: { michael@0: if (i == 100) michael@0: continue; michael@0: j++; michael@0: } michael@0: michael@0: // '"continue" in a "for" loop' michael@0: new TestCase ( SECTION, '"continue" in "for" loop', michael@0: 199, j); michael@0: michael@0: michael@0: j = 0; michael@0: out1: michael@0: for (i = 0; i < 1000; i++) michael@0: { michael@0: if (i == 100) michael@0: { michael@0: out2: michael@0: for (var k = 0; k < 1000; k++) michael@0: { michael@0: if (k == 500) continue out1; michael@0: } michael@0: j = 3000; michael@0: } michael@0: j++; michael@0: } michael@0: michael@0: // '"continue" in a "for" loop with a "label"' michael@0: new TestCase ( SECTION, '"continue" in "for" loop with a "label"', michael@0: 999, j); michael@0: michael@0: i = 0; michael@0: j = 1; michael@0: michael@0: while (i != j) michael@0: { michael@0: i++; michael@0: if (i == 100) continue; michael@0: j++; michael@0: } michael@0: michael@0: // '"continue" in a "while" loop' michael@0: new TestCase ( SECTION, '"continue" in a "while" loop', michael@0: 100, j ); michael@0: michael@0: j = 0; michael@0: i = 0; michael@0: out3: michael@0: while (i < 1000) michael@0: { michael@0: if (i == 100) michael@0: { michael@0: var k = 0; michael@0: out4: michael@0: while (k < 1000) michael@0: { michael@0: if (k == 500) michael@0: { michael@0: i++; michael@0: continue out3; michael@0: } michael@0: k++; michael@0: } michael@0: j = 3000; michael@0: } michael@0: j++; michael@0: i++; michael@0: } michael@0: michael@0: // '"continue" in a "while" loop with a "label"' michael@0: new TestCase ( SECTION, '"continue" in a "while" loop with a "label"', michael@0: 999, j); michael@0: michael@0: i = 0; michael@0: j = 1; michael@0: michael@0: do michael@0: { michael@0: i++; michael@0: if (i == 100) continue; michael@0: j++; michael@0: } while (i != j); michael@0: michael@0: michael@0: // '"continue" in a "do" loop' michael@0: new TestCase ( SECTION, '"continue" in a "do" loop', michael@0: 100, j ); michael@0: michael@0: j = 0; michael@0: i = 0; michael@0: out5: michael@0: do michael@0: { michael@0: if (i == 100) michael@0: { michael@0: var k = 0; michael@0: out6: michael@0: do michael@0: { michael@0: if (k == 500) michael@0: { michael@0: i++; michael@0: continue out5; michael@0: } michael@0: k++; michael@0: }while (k < 1000); michael@0: j = 3000; michael@0: } michael@0: j++; michael@0: i++; michael@0: }while (i < 1000); michael@0: michael@0: // '"continue" in a "do" loop with a "label"' michael@0: new TestCase ( SECTION, '"continue" in a "do" loop with a "label"', michael@0: 999, j); michael@0: michael@0: test();