js/src/tests/ecma_6/Expressions/octal-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 octal literals";
     8 print(BUGNUMBER + ": " + summary);
    10 /**************
    11  * BEGIN TEST *
    12  **************/
    14 var chars = ['o', 'O'];
    16 for (var i = 0; i < 8; i++)
    17 {
    18   if (i === 8)
    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 < 8; j++)
    38   {
    39     if (j === 8)
    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 < 8; k++)
    59     {
    60       if (k === 8)
    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 * 64 + j * 8 + k);
    82       });
    83     }
    84   }
    85 }
    87 // Off-by-one check: '/' immediately precedes '0'.
    88 assertEq(0o110/2, 36);
    89 assertEq(0O644/2, 210);
    91 function strict()
    92 {
    93   "use strict";
    94   return 0o755;
    95 }
    96 assertEq(strict(), 7 * 64 + 5 * 8 + 5);
    98 /******************************************************************************/
   100 if (typeof reportCompare === "function")
   101   reportCompare(true, true);
   103 print("Tests complete");

mercurial