js/src/tests/ecma_3/Statements/switch-001.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/. */
     6 /*
     7  * Date: 07 May 2001
     8  *
     9  * SUMMARY: Testing the switch statement
    10  *
    11  * See ECMA3  Section 12.11,  "The switch Statement"
    12  */
    13 //-----------------------------------------------------------------------------
    14 var UBound = 0;
    15 var BUGNUMBER = '(none)';
    16 var summary = 'Testing the switch statement';
    17 var cnMatch = 'Match';
    18 var cnNoMatch = 'NoMatch';
    19 var status = '';
    20 var statusitems = [ ];
    21 var actual = '';
    22 var actualvalues = [ ];
    23 var expect= '';
    24 var expectedvalues = [ ];
    27 status = 'Section A of test';
    28 actual = match(17, f(fInverse(17)), f, fInverse);
    29 expect = cnMatch;
    30 addThis();
    32 status = 'Section B of test';
    33 actual = match(17, 18, f, fInverse);
    34 expect = cnNoMatch;
    35 addThis();
    37 status = 'Section C of test';
    38 actual = match(1, 1, Math.exp, Math.log);
    39 expect = cnMatch;
    40 addThis();
    42 status = 'Section D of test';
    43 actual = match(1, 2, Math.exp, Math.log);
    44 expect = cnNoMatch;
    45 addThis();
    47 status = 'Section E of test';
    48 actual = match(1, 1, Math.sin, Math.cos);
    49 expect = cnNoMatch;
    50 addThis();
    54 //---------------------------------------------------------------------------------
    55 test();
    56 //---------------------------------------------------------------------------------
    60 /*
    61  * If F,G are inverse functions and x==y, this should return cnMatch -
    62  */
    63 function match(x, y, F, G)
    64 {
    65   switch (x)
    66   {
    67   case F(G(y)):
    68     return cnMatch;
    70   default:
    71     return cnNoMatch;
    72   }
    73 }
    76 function addThis()
    77 {
    78   statusitems[UBound] = status;
    79   actualvalues[UBound] = actual;
    80   expectedvalues[UBound] = expect;
    81   UBound++;
    82 }
    85 function test()
    86 {
    87   enterFunc ('test');
    88   printBugNumber(BUGNUMBER);
    89   printStatus (summary);
    91   for (var i = 0; i < UBound; i++)
    92   {
    93     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
    94   }
    96   exitFunc ('test');
    97 }
   100 function f(m)
   101 {
   102   return 2*(m+1);
   103 }
   106 function fInverse(n)
   107 {
   108   return (n-2)/2;
   109 }

mercurial