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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_2/Statements/switch-003.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +
    1.10 +/**
    1.11 + *  File Name:          switch-003.js
    1.12 + *  ECMA Section:
    1.13 + *  Description:        The switch Statement
    1.14 + *
    1.15 + *  Attempt to verify that case statements are evaluated in source order
    1.16 + *
    1.17 + *  Author:             christine@netscape.com
    1.18 + *  Date:               11 August 1998
    1.19 + *
    1.20 + */
    1.21 +var SECTION = "switch-003";
    1.22 +var VERSION = "ECMA_2";
    1.23 +var TITLE   = "The switch statement";
    1.24 +
    1.25 +startTest();
    1.26 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.27 +
    1.28 +SwitchTest( "a", "abc" );
    1.29 +SwitchTest( "b", "bc" );
    1.30 +SwitchTest( "c", "c" );
    1.31 +SwitchTest( "d", "*abc" );
    1.32 +SwitchTest( "v", "*abc" );
    1.33 +SwitchTest( "w", "w*abc" );
    1.34 +SwitchTest( "x", "xw*abc" );
    1.35 +SwitchTest( "y", "yxw*abc" );
    1.36 +SwitchTest( "z", "zyxw*abc" );
    1.37 +//    SwitchTest( new java.lang.String("z"), "*abc" );
    1.38 +
    1.39 +test();
    1.40 +
    1.41 +function SwitchTest( input, expect ) {
    1.42 +  var result = "";
    1.43 +
    1.44 +  switch ( input ) {
    1.45 +  case "z": result += "z";
    1.46 +  case "y": result += "y";
    1.47 +  case "x": result += "x";
    1.48 +  case "w": result += "w";
    1.49 +  default: result += "*";
    1.50 +  case "a": result += "a";
    1.51 +  case "b": result += "b";
    1.52 +  case "c": result += "c";
    1.53 +  }
    1.54 +
    1.55 +  new TestCase(
    1.56 +    SECTION,
    1.57 +    "switch with no breaks:  input is " + input,
    1.58 +    expect,
    1.59 +    result );
    1.60 +}

mercurial