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 octal literals"; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: var chars = ['o', 'O']; michael@0: michael@0: for (var i = 0; i < 8; i++) michael@0: { michael@0: if (i === 8) 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 < 8; j++) michael@0: { michael@0: if (j === 8) 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 < 8; k++) michael@0: { michael@0: if (k === 8) 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 * 64 + j * 8 + k); michael@0: }); michael@0: } michael@0: } michael@0: } michael@0: michael@0: // Off-by-one check: '/' immediately precedes '0'. michael@0: assertEq(0o110/2, 36); michael@0: assertEq(0O644/2, 210); michael@0: michael@0: function strict() michael@0: { michael@0: "use strict"; michael@0: return 0o755; michael@0: } michael@0: assertEq(strict(), 7 * 64 + 5 * 8 + 5); michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("Tests complete");