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.

michael@0 1 // Any copyright is dedicated to the Public Domain.
michael@0 2 // http://creativecommons.org/licenses/publicdomain/
michael@0 3
michael@0 4 //-----------------------------------------------------------------------------
michael@0 5 var BUGNUMBER = 894026;
michael@0 6 var summary = "Implement ES6 octal literals";
michael@0 7
michael@0 8 print(BUGNUMBER + ": " + summary);
michael@0 9
michael@0 10 /**************
michael@0 11 * BEGIN TEST *
michael@0 12 **************/
michael@0 13
michael@0 14 var chars = ['o', 'O'];
michael@0 15
michael@0 16 for (var i = 0; i < 8; i++)
michael@0 17 {
michael@0 18 if (i === 8)
michael@0 19 {
michael@0 20 chars.forEach(function(v)
michael@0 21 {
michael@0 22 try
michael@0 23 {
michael@0 24 eval('0' + v + i);
michael@0 25 throw "didn't throw";
michael@0 26 }
michael@0 27 catch (e)
michael@0 28 {
michael@0 29 assertEq(e instanceof SyntaxError, true,
michael@0 30 "no syntax error evaluating 0" + v + i + ", " +
michael@0 31 "got " + e);
michael@0 32 }
michael@0 33 });
michael@0 34 continue;
michael@0 35 }
michael@0 36
michael@0 37 for (var j = 0; j < 8; j++)
michael@0 38 {
michael@0 39 if (j === 8)
michael@0 40 {
michael@0 41 chars.forEach(function(v)
michael@0 42 {
michael@0 43 try
michael@0 44 {
michael@0 45 eval('0' + v + i + j);
michael@0 46 throw "didn't throw";
michael@0 47 }
michael@0 48 catch (e)
michael@0 49 {
michael@0 50 assertEq(e instanceof SyntaxError, true,
michael@0 51 "no syntax error evaluating 0" + v + i + j + ", " +
michael@0 52 "got " + e);
michael@0 53 }
michael@0 54 });
michael@0 55 continue;
michael@0 56 }
michael@0 57
michael@0 58 for (var k = 0; k < 8; k++)
michael@0 59 {
michael@0 60 if (k === 8)
michael@0 61 {
michael@0 62 chars.forEach(function(v)
michael@0 63 {
michael@0 64 try
michael@0 65 {
michael@0 66 eval('0' + v + i + j + k);
michael@0 67 throw "didn't throw";
michael@0 68 }
michael@0 69 catch (e)
michael@0 70 {
michael@0 71 assertEq(e instanceof SyntaxError, true,
michael@0 72 "no syntax error evaluating 0" + v + i + j + k + ", " +
michael@0 73 "got " + e);
michael@0 74 }
michael@0 75 });
michael@0 76 continue;
michael@0 77 }
michael@0 78
michael@0 79 chars.forEach(function(v)
michael@0 80 {
michael@0 81 assertEq(eval('0' + v + i + j + k), i * 64 + j * 8 + k);
michael@0 82 });
michael@0 83 }
michael@0 84 }
michael@0 85 }
michael@0 86
michael@0 87 // Off-by-one check: '/' immediately precedes '0'.
michael@0 88 assertEq(0o110/2, 36);
michael@0 89 assertEq(0O644/2, 210);
michael@0 90
michael@0 91 function strict()
michael@0 92 {
michael@0 93 "use strict";
michael@0 94 return 0o755;
michael@0 95 }
michael@0 96 assertEq(strict(), 7 * 64 + 5 * 8 + 5);
michael@0 97
michael@0 98 /******************************************************************************/
michael@0 99
michael@0 100 if (typeof reportCompare === "function")
michael@0 101 reportCompare(true, true);
michael@0 102
michael@0 103 print("Tests complete");

mercurial