js/src/tests/js1_2/statements/switch.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6
michael@0 7 /**
michael@0 8 Filename: switch.js
michael@0 9 Description: 'Tests the switch statement'
michael@0 10
michael@0 11 http://scopus.mcom.com/bugsplat/show_bug.cgi?id=323696
michael@0 12
michael@0 13 Author: Nick Lerissa
michael@0 14 Date: March 19, 1998
michael@0 15 */
michael@0 16
michael@0 17 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
michael@0 18 var VERSION = 'no version';
michael@0 19 var TITLE = 'statements: switch';
michael@0 20 var BUGNUMBER="323696";
michael@0 21
michael@0 22 startTest();
michael@0 23 writeHeaderToLog("Executing script: switch.js");
michael@0 24 writeHeaderToLog( SECTION + " "+ TITLE);
michael@0 25
michael@0 26
michael@0 27 var var1 = "match string";
michael@0 28 var match1 = false;
michael@0 29 var match2 = false;
michael@0 30 var match3 = false;
michael@0 31
michael@0 32 switch (var1)
michael@0 33 {
michael@0 34 case "match string":
michael@0 35 match1 = true;
michael@0 36 case "bad string 1":
michael@0 37 match2 = true;
michael@0 38 break;
michael@0 39 case "bad string 2":
michael@0 40 match3 = true;
michael@0 41 }
michael@0 42
michael@0 43 new TestCase ( SECTION, 'switch statement',
michael@0 44 true, match1);
michael@0 45
michael@0 46 new TestCase ( SECTION, 'switch statement',
michael@0 47 true, match2);
michael@0 48
michael@0 49 new TestCase ( SECTION, 'switch statement',
michael@0 50 false, match3);
michael@0 51
michael@0 52 var var2 = 3;
michael@0 53
michael@0 54 var match1 = false;
michael@0 55 var match2 = false;
michael@0 56 var match3 = false;
michael@0 57 var match4 = false;
michael@0 58 var match5 = false;
michael@0 59
michael@0 60 switch (var2)
michael@0 61 {
michael@0 62 case 1:
michael@0 63 /* switch (var1)
michael@0 64 {
michael@0 65 case "foo":
michael@0 66 match1 = true;
michael@0 67 break;
michael@0 68 case 3:
michael@0 69 match2 = true;
michael@0 70 break;
michael@0 71 }*/
michael@0 72 match3 = true;
michael@0 73 break;
michael@0 74 case 2:
michael@0 75 match4 = true;
michael@0 76 break;
michael@0 77 case 3:
michael@0 78 match5 = true;
michael@0 79 break;
michael@0 80 }
michael@0 81 new TestCase ( SECTION, 'switch statement',
michael@0 82 false, match1);
michael@0 83
michael@0 84 new TestCase ( SECTION, 'switch statement',
michael@0 85 false, match2);
michael@0 86
michael@0 87 new TestCase ( SECTION, 'switch statement',
michael@0 88 false, match3);
michael@0 89
michael@0 90 new TestCase ( SECTION, 'switch statement',
michael@0 91 false, match4);
michael@0 92
michael@0 93 new TestCase ( SECTION, 'switch statement',
michael@0 94 true, match5);
michael@0 95
michael@0 96 test();

mercurial