Debian Codegraph @

rhino/testsrc/tests/ecma_2/Statements/switch-001.js

raw symbols SCIP
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 gTestfile = 'switch-001.js';
7
8 /**
9 * File Name: switch-001.js
10 * ECMA Section:
11 * Description: The switch Statement
12 *
13 * A simple switch test with no abrupt completions.
14 *
15 * Author: [email protected]
16 * Date: 11 August 1998
17 *
18 */
19 var SECTION = "switch-001";
20 var VERSION = "ECMA_2";
21 var TITLE = "The switch statement";
22
23 var BUGNUMBER="315767";
24
25 startTest();
26 writeHeaderToLog( SECTION + " "+ TITLE);
27
28 SwitchTest( 0, 126 );
29 SwitchTest( 1, 124 );
30 SwitchTest( 2, 120 );
31 SwitchTest( 3, 112 );
32 SwitchTest( 4, 64 );
33 SwitchTest( 5, 96 );
34 SwitchTest( true, 96 );
35 SwitchTest( false, 96 );
36 SwitchTest( null, 96 );
37 SwitchTest( void 0, 96 );
38 SwitchTest( "0", 96 );
39
40 test();
41
42 function SwitchTest( input, expect ) {
43 var result = 0;
44
45 switch ( input ) {
46 case 0:
47 result += 2;
48 case 1:
49 result += 4;
50 case 2:
51 result += 8;
52 case 3:
53 result += 16;
54 default:
55 result += 32;
56 case 4:
57 result +=64;
58 }
59
60 new TestCase(
61 SECTION,
62 "switch with no breaks, case expressions are numbers. input is "+
63 input,
64 expect,
65 result );
66 }