|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 |
|
7 /** |
|
8 * File Name: switch-003.js |
|
9 * ECMA Section: |
|
10 * Description: The switch Statement |
|
11 * |
|
12 * Attempt to verify that case statements are evaluated in source order |
|
13 * |
|
14 * Author: christine@netscape.com |
|
15 * Date: 11 August 1998 |
|
16 * |
|
17 */ |
|
18 var SECTION = "switch-003"; |
|
19 var VERSION = "ECMA_2"; |
|
20 var TITLE = "The switch statement"; |
|
21 |
|
22 startTest(); |
|
23 writeHeaderToLog( SECTION + " "+ TITLE); |
|
24 |
|
25 SwitchTest( "a", "abc" ); |
|
26 SwitchTest( "b", "bc" ); |
|
27 SwitchTest( "c", "c" ); |
|
28 SwitchTest( "d", "*abc" ); |
|
29 SwitchTest( "v", "*abc" ); |
|
30 SwitchTest( "w", "w*abc" ); |
|
31 SwitchTest( "x", "xw*abc" ); |
|
32 SwitchTest( "y", "yxw*abc" ); |
|
33 SwitchTest( "z", "zyxw*abc" ); |
|
34 // SwitchTest( new java.lang.String("z"), "*abc" ); |
|
35 |
|
36 test(); |
|
37 |
|
38 function SwitchTest( input, expect ) { |
|
39 var result = ""; |
|
40 |
|
41 switch ( input ) { |
|
42 case "z": result += "z"; |
|
43 case "y": result += "y"; |
|
44 case "x": result += "x"; |
|
45 case "w": result += "w"; |
|
46 default: result += "*"; |
|
47 case "a": result += "a"; |
|
48 case "b": result += "b"; |
|
49 case "c": result += "c"; |
|
50 } |
|
51 |
|
52 new TestCase( |
|
53 SECTION, |
|
54 "switch with no breaks: input is " + input, |
|
55 expect, |
|
56 result ); |
|
57 } |