]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/js1_2/statements/switch2.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
24 Description: 'Tests the switch statement'
26 http://scopus.mcom.com/bugsplat/show_bug.cgi?id=323696
32 var SECTION
= 'As described in Netscape doc "Whats new in JavaScript 1.2"';
33 var VERSION
= 'no version';
35 var TITLE
= 'statements: switch';
36 var BUGNUMBER
="323626";
38 writeHeaderToLog("Executing script: switch2.js");
39 writeHeaderToLog( SECTION
+ " "+ TITLE
);
42 var testcases
= new Array();
44 // test defaults not at the end; regression test for a bug that
45 // nearly made it into 4.06
59 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
62 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
65 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
68 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
71 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
88 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
91 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
94 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
97 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
100 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
103 // Switch on integer; will use TABLESWITCH opcode in C engine
112 // with no default, control will fall through
116 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
119 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
122 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
125 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
128 // empty switch: make sure expression is evaluated
132 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
141 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
144 // in loop, break should only break out of switch
146 for (var i
=0; i
< 2; i
++) {
154 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
157 // test "fall through"
168 testcases
[count
++] = new TestCase(SECTION
, 'switch statement',
173 // Needed: tests for evaluation time of case expressions.
174 // This issue was under debate at ECMA, so postponing for now.
177 writeLineToLog("hi");
178 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
179 testcases
[tc
].passed
= writeTestCaseResult(
180 testcases
[tc
].expect
,
181 testcases
[tc
].actual
,
182 testcases
[tc
].description
+" = "+
183 testcases
[tc
].actual
);
184 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
187 return ( testcases
);