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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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-002.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-002";
    19 var VERSION = "ECMA_2";
    20 var TITLE   = "The switch statement";
    22 startTest();
    23 writeHeaderToLog( SECTION + " "+ TITLE);
    25 SwitchTest( 0, 6 );
    26 SwitchTest( 1, 4 );
    27 SwitchTest( 2, 56 );
    28 SwitchTest( 3, 48 );
    29 SwitchTest( 4, 64 );
    30 SwitchTest( true, 32 );
    31 SwitchTest( false, 32 );
    32 SwitchTest( null, 32 );
    33 SwitchTest( void 0, 32 );
    34 SwitchTest( "0", 32 );
    36 test();
    38 function SwitchTest( input, expect ) {
    39   var result = 0;
    41   switch ( input ) {
    42   case 0:
    43     result += 2;
    44   case 1:
    45     result += 4;
    46     break;
    47   case 2:
    48     result += 8;
    49   case 3:
    50     result += 16;
    51   default:
    52     result += 32;
    53     break;
    54   case 4:
    55     result += 64;
    56   }
    58   new TestCase(
    59     SECTION,
    60     "switch with no breaks:  input is " + input,
    61     expect,
    62     result );
    63 }

mercurial