js/src/tests/ecma_6/Expressions/binary-literals.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 // Any copyright is dedicated to the Public Domain.
     2 // http://creativecommons.org/licenses/publicdomain/
     4 //-----------------------------------------------------------------------------
     5 var BUGNUMBER = 894026;
     6 var summary = "Implement ES6 binary literals";
     8 print(BUGNUMBER + ": " + summary);
    10 /**************
    11  * BEGIN TEST *
    12  **************/
    14 var chars = ['b', 'B'];
    16 for (var i = 0; i < 2; i++)
    17 {
    18   if (i === 2)
    19   {
    20     chars.forEach(function(v)
    21     {
    22       try
    23       {
    24         eval('0' + v + i);
    25         throw "didn't throw";
    26       }
    27       catch (e)
    28       {
    29         assertEq(e instanceof SyntaxError, true,
    30                  "no syntax error evaluating 0" + v + i + ", " +
    31                  "got " + e);
    32       }
    33     });
    34     continue;
    35   }
    37   for (var j = 0; j < 2; j++)
    38   {
    39     if (j === 2)
    40     {
    41       chars.forEach(function(v)
    42       {
    43         try
    44         {
    45           eval('0' + v + i + j);
    46           throw "didn't throw";
    47         }
    48         catch (e)
    49         {
    50           assertEq(e instanceof SyntaxError, true,
    51                    "no syntax error evaluating 0" + v + i + j + ", " +
    52                    "got " + e);
    53         }
    54       });
    55       continue;
    56     }
    58     for (var k = 0; k < 2; k++)
    59     {
    60       if (k === 2)
    61       {
    62         chars.forEach(function(v)
    63         {
    64           try
    65           {
    66             eval('0' + v + i + j + k);
    67             throw "didn't throw";
    68           }
    69           catch (e)
    70           {
    71             assertEq(e instanceof SyntaxError, true,
    72                      "no syntax error evaluating 0" + v + i + j + k + ", " +
    73                      "got " + e);
    74           }
    75         });
    76         continue;
    77       }
    79       chars.forEach(function(v)
    80       {
    81         assertEq(eval('0' + v + i + j + k), i * 4 + j * 2 + k);
    82       });
    83     }
    84   }
    85 }
    87 chars.forEach(function(v)
    88 {
    89   try
    90   {
    91   }
    92   catch (e)
    93   {
    94     assertEq(e instanceof SyntaxError, true,
    95              "no syntax error evaluating 0" + v + ", got " + e);
    96   }
    97 });
    99 // Off-by-one check: '/' immediately precedes '0'.
   100 assertEq(0b110/1, 6);
   101 assertEq(0B10110/1, 22);
   103 function strict()
   104 {
   105   "use strict";
   106   return 0b11010101;
   107 }
   108 assertEq(strict(), 128 + 64 + 16 + 4 + 1);
   110 /******************************************************************************/
   112 if (typeof reportCompare === "function")
   113   reportCompare(true, true);
   115 print("Tests complete");

mercurial