michael@0: // Any copyright is dedicated to the Public Domain. michael@0: // http://creativecommons.org/licenses/publicdomain/ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 894026; michael@0: var summary = "Implement ES6 binary literals"; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: var chars = ['b', 'B']; michael@0: michael@0: for (var i = 0; i < 2; i++) michael@0: { michael@0: if (i === 2) michael@0: { michael@0: chars.forEach(function(v) michael@0: { michael@0: try michael@0: { michael@0: eval('0' + v + i); michael@0: throw "didn't throw"; michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(e instanceof SyntaxError, true, michael@0: "no syntax error evaluating 0" + v + i + ", " + michael@0: "got " + e); michael@0: } michael@0: }); michael@0: continue; michael@0: } michael@0: michael@0: for (var j = 0; j < 2; j++) michael@0: { michael@0: if (j === 2) michael@0: { michael@0: chars.forEach(function(v) michael@0: { michael@0: try michael@0: { michael@0: eval('0' + v + i + j); michael@0: throw "didn't throw"; michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(e instanceof SyntaxError, true, michael@0: "no syntax error evaluating 0" + v + i + j + ", " + michael@0: "got " + e); michael@0: } michael@0: }); michael@0: continue; michael@0: } michael@0: michael@0: for (var k = 0; k < 2; k++) michael@0: { michael@0: if (k === 2) michael@0: { michael@0: chars.forEach(function(v) michael@0: { michael@0: try michael@0: { michael@0: eval('0' + v + i + j + k); michael@0: throw "didn't throw"; michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(e instanceof SyntaxError, true, michael@0: "no syntax error evaluating 0" + v + i + j + k + ", " + michael@0: "got " + e); michael@0: } michael@0: }); michael@0: continue; michael@0: } michael@0: michael@0: chars.forEach(function(v) michael@0: { michael@0: assertEq(eval('0' + v + i + j + k), i * 4 + j * 2 + k); michael@0: }); michael@0: } michael@0: } michael@0: } michael@0: michael@0: chars.forEach(function(v) michael@0: { michael@0: try michael@0: { michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(e instanceof SyntaxError, true, michael@0: "no syntax error evaluating 0" + v + ", got " + e); michael@0: } michael@0: }); michael@0: michael@0: // Off-by-one check: '/' immediately precedes '0'. michael@0: assertEq(0b110/1, 6); michael@0: assertEq(0B10110/1, 22); michael@0: michael@0: function strict() michael@0: { michael@0: "use strict"; michael@0: return 0b11010101; michael@0: } michael@0: assertEq(strict(), 128 + 64 + 16 + 4 + 1); michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("Tests complete");