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: switch.js michael@0: Description: 'Tests the switch statement' michael@0: michael@0: http://scopus.mcom.com/bugsplat/show_bug.cgi?id=323696 michael@0: michael@0: Author: Nick Lerissa michael@0: Date: March 19, 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: var TITLE = 'statements: switch'; michael@0: var BUGNUMBER="323696"; michael@0: michael@0: startTest(); michael@0: writeHeaderToLog("Executing script: switch.js"); michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: michael@0: var var1 = "match string"; michael@0: var match1 = false; michael@0: var match2 = false; michael@0: var match3 = false; michael@0: michael@0: switch (var1) michael@0: { michael@0: case "match string": michael@0: match1 = true; michael@0: case "bad string 1": michael@0: match2 = true; michael@0: break; michael@0: case "bad string 2": michael@0: match3 = true; michael@0: } michael@0: michael@0: new TestCase ( SECTION, 'switch statement', michael@0: true, match1); michael@0: michael@0: new TestCase ( SECTION, 'switch statement', michael@0: true, match2); michael@0: michael@0: new TestCase ( SECTION, 'switch statement', michael@0: false, match3); michael@0: michael@0: var var2 = 3; michael@0: michael@0: var match1 = false; michael@0: var match2 = false; michael@0: var match3 = false; michael@0: var match4 = false; michael@0: var match5 = false; michael@0: michael@0: switch (var2) michael@0: { michael@0: case 1: michael@0: /* switch (var1) michael@0: { michael@0: case "foo": michael@0: match1 = true; michael@0: break; michael@0: case 3: michael@0: match2 = true; michael@0: break; michael@0: }*/ michael@0: match3 = true; michael@0: break; michael@0: case 2: michael@0: match4 = true; michael@0: break; michael@0: case 3: michael@0: match5 = true; michael@0: break; michael@0: } michael@0: new TestCase ( SECTION, 'switch statement', michael@0: false, match1); michael@0: michael@0: new TestCase ( SECTION, 'switch statement', michael@0: false, match2); michael@0: michael@0: new TestCase ( SECTION, 'switch statement', michael@0: false, match3); michael@0: michael@0: new TestCase ( SECTION, 'switch statement', michael@0: false, match4); michael@0: michael@0: new TestCase ( SECTION, 'switch statement', michael@0: true, match5); michael@0: michael@0: test();