js/src/tests/ecma_2/Statements/switch-001.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial