initial import
[vuplus_webkit] / Source / JavaScriptCore / tests / mozilla / ecma_2 / Statements / switch-003.js
1 /**
2  *  File Name:          switch-003.js
3  *  ECMA Section:
4  *  Description:        The switch Statement
5  *
6  *  Attempt to verify that case statements are evaluated in source order
7  *
8  *  Author:             christine@netscape.com
9  *  Date:               11 August 1998
10  *
11  */
12     var SECTION = "switch-003";
13     var VERSION = "ECMA_2";
14     var TITLE   = "The switch statement";
15
16     startTest();
17     writeHeaderToLog( SECTION + " "+ TITLE);
18
19     var tc = 0;
20     var testcases = new Array();
21
22     SwitchTest( "a", "abc" );
23     SwitchTest( "b", "bc" );
24     SwitchTest( "c", "c" );
25     SwitchTest( "d", "*abc" );
26     SwitchTest( "v", "*abc" );
27     SwitchTest( "w", "w*abc" );
28     SwitchTest( "x", "xw*abc" );
29     SwitchTest( "y", "yxw*abc" );
30     SwitchTest( "z", "zyxw*abc" );
31 //    SwitchTest( new java.lang.String("z"), "*abc" );
32
33     test();
34
35     function SwitchTest( input, expect ) {
36         var result = "";
37
38         switch ( input ) {
39             case "z": result += "z";
40             case "y": result += "y";
41             case "x": result += "x";
42             case "w": result += "w";
43             default: result += "*";
44             case "a": result += "a";
45             case "b": result += "b";
46             case "c": result += "c";
47         }
48
49         testcases[tc++] = new TestCase(
50             SECTION,
51             "switch with no breaks:  input is " + input,
52             expect,
53             result );
54     }