]> git.saurik.com Git - apple/javascriptcore.git/blame - tests/mozilla/js1_2/statements/switch.js
JavaScriptCore-461.tar.gz
[apple/javascriptcore.git] / tests / mozilla / js1_2 / statements / switch.js
CommitLineData
b37bf2e1
A
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/
5 *
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.
10 *
11 * The Original Code is Mozilla Communicator client code, released March
12 * 31, 1998.
13 *
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
17 * Rights Reserved.
18 *
19 * Contributor(s):
20 *
21 */
22/**
23 Filename: switch.js
24 Description: 'Tests the switch statement'
25
26 http://scopus.mcom.com/bugsplat/show_bug.cgi?id=323696
27
28 Author: Nick Lerissa
29 Date: March 19, 1998
30*/
31
32 var SECTION = 'As described in Netscape doc "Whats new in JavaScript 1.2"';
33 var VERSION = 'no version';
34 startTest();
35 var TITLE = 'statements: switch';
36 var BUGNUMBER="323696";
37
38 writeHeaderToLog("Executing script: switch.js");
39 writeHeaderToLog( SECTION + " "+ TITLE);
40
41 var count = 0;
42 var testcases = new Array();
43
44 var var1 = "match string";
45 var match1 = false;
46 var match2 = false;
47 var match3 = false;
48
49 switch (var1)
50 {
51 case "match string":
52 match1 = true;
53 case "bad string 1":
54 match2 = true;
55 break;
56 case "bad string 2":
57 match3 = true;
58 }
59
60 testcases[count++] = new TestCase ( SECTION, 'switch statement',
61 true, match1);
62
63 testcases[count++] = new TestCase ( SECTION, 'switch statement',
64 true, match2);
65
66 testcases[count++] = new TestCase ( SECTION, 'switch statement',
67 false, match3);
68
69 var var2 = 3;
70
71 var match1 = false;
72 var match2 = false;
73 var match3 = false;
74 var match4 = false;
75 var match5 = false;
76
77 switch (var2)
78 {
79 case 1:
80/* switch (var1)
81 {
82 case "foo":
83 match1 = true;
84 break;
85 case 3:
86 match2 = true;
87 break;
88 }*/
89 match3 = true;
90 break;
91 case 2:
92 match4 = true;
93 break;
94 case 3:
95 match5 = true;
96 break;
97 }
98 testcases[count++] = new TestCase ( SECTION, 'switch statement',
99 false, match1);
100
101 testcases[count++] = new TestCase ( SECTION, 'switch statement',
102 false, match2);
103
104 testcases[count++] = new TestCase ( SECTION, 'switch statement',
105 false, match3);
106
107 testcases[count++] = new TestCase ( SECTION, 'switch statement',
108 false, match4);
109
110 testcases[count++] = new TestCase ( SECTION, 'switch statement',
111 true, match5);
112
113 function test()
114 {
115 for ( tc=0; tc < testcases.length; tc++ ) {
116 testcases[tc].passed = writeTestCaseResult(
117 testcases[tc].expect,
118 testcases[tc].actual,
119 testcases[tc].description +" = "+
120 testcases[tc].actual );
121 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
122 }
123 stopTest();
124 return ( testcases );
125 }
126
127 test();