js/src/tests/ecma_2/Statements/switch-004.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.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6
michael@0 7 /**
michael@0 8 * File Name: switch-003.js
michael@0 9 * ECMA Section:
michael@0 10 * Description: The switch Statement
michael@0 11 *
michael@0 12 * This uses variables and objects as case expressions in switch statements.
michael@0 13 * This verifies a bunch of bugs:
michael@0 14 *
michael@0 15 * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315988
michael@0 16 * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315975
michael@0 17 * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315954
michael@0 18 *
michael@0 19 * Author: christine@netscape.com
michael@0 20 * Date: 11 August 1998
michael@0 21 *
michael@0 22 */
michael@0 23 var SECTION = "switch-003";
michael@0 24 var VERSION = "ECMA_2";
michael@0 25 var TITLE = "The switch statement";
michael@0 26 var BUGNUMBER= "315988";
michael@0 27
michael@0 28 startTest();
michael@0 29 writeHeaderToLog( SECTION + " "+ TITLE);
michael@0 30
michael@0 31 ONE = new Number(1);
michael@0 32 ZERO = new Number(0);
michael@0 33 var A = new String("A");
michael@0 34 var B = new String("B");
michael@0 35 TRUE = new Boolean( true );
michael@0 36 FALSE = new Boolean( false );
michael@0 37 UNDEFINED = void 0;
michael@0 38 NULL = null;
michael@0 39
michael@0 40 SwitchTest( ZERO, "ZERO" );
michael@0 41 SwitchTest( NULL, "NULL" );
michael@0 42 SwitchTest( UNDEFINED, "UNDEFINED" );
michael@0 43 SwitchTest( FALSE, "FALSE" );
michael@0 44 SwitchTest( false, "false" );
michael@0 45 SwitchTest( 0, "0" );
michael@0 46
michael@0 47 SwitchTest ( TRUE, "TRUE" );
michael@0 48 SwitchTest( 1, "1" );
michael@0 49 SwitchTest( ONE, "ONE" );
michael@0 50 SwitchTest( true, "true" );
michael@0 51
michael@0 52 SwitchTest( "a", "a" );
michael@0 53 SwitchTest( A, "A" );
michael@0 54 SwitchTest( "b", "b" );
michael@0 55 SwitchTest( B, "B" );
michael@0 56
michael@0 57 SwitchTest( new Boolean( true ), "default" );
michael@0 58 SwitchTest( new Boolean(false ), "default" );
michael@0 59 SwitchTest( new String( "A" ), "default" );
michael@0 60 SwitchTest( new Number( 0 ), "default" );
michael@0 61
michael@0 62 test();
michael@0 63
michael@0 64 function SwitchTest( input, expect ) {
michael@0 65 var result = "";
michael@0 66
michael@0 67 switch ( input ) {
michael@0 68 default: result += "default"; break;
michael@0 69 case "a": result += "a"; break;
michael@0 70 case "b": result += "b"; break;
michael@0 71 case A: result += "A"; break;
michael@0 72 case B: result += "B"; break;
michael@0 73 case new Boolean(true): result += "new TRUE"; break;
michael@0 74 case new Boolean(false): result += "new FALSE"; break;
michael@0 75 case NULL: result += "NULL"; break;
michael@0 76 case UNDEFINED: result += "UNDEFINED"; break;
michael@0 77 case true: result += "true"; break;
michael@0 78 case false: result += "false"; break;
michael@0 79 case TRUE: result += "TRUE"; break;
michael@0 80 case FALSE: result += "FALSE"; break;
michael@0 81 case 0: result += "0"; break;
michael@0 82 case 1: result += "1"; break;
michael@0 83 case new Number(0) : result += "new ZERO"; break;
michael@0 84 case new Number(1) : result += "new ONE"; break;
michael@0 85 case ONE: result += "ONE"; break;
michael@0 86 case ZERO: result += "ZERO"; break;
michael@0 87 }
michael@0 88
michael@0 89 new TestCase(
michael@0 90 SECTION,
michael@0 91 "switch with no breaks: input is " + input,
michael@0 92 expect,
michael@0 93 result );
michael@0 94 }

mercurial