From 642273c29002e7676719f489d7fcf552974118f4 Mon Sep 17 00:00:00 2001 From: Anthony Van de Gejuchte Date: Thu, 21 Jul 2016 03:19:24 +0200 Subject: Legacy octal integer strict mode fixes --- test/mocha/number-literal.js | 24 ++++++++++++++++++++++++ test/mocha/string-literal.js | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/mocha/number-literal.js (limited to 'test/mocha') diff --git a/test/mocha/number-literal.js b/test/mocha/number-literal.js new file mode 100644 index 00000000..8e05574a --- /dev/null +++ b/test/mocha/number-literal.js @@ -0,0 +1,24 @@ +var assert = require("assert"); +var uglify = require("../../"); + +describe("Number literals", function () { + it("Should not allow legacy octal literals in strict mode", function() { + var inputs = [ + '"use strict";00;', + '"use strict"; var foo = 00;' + ]; + + var test = function(input) { + return function() { + uglify.parse(input); + } + } + var error = function(e) { + return e instanceof uglify.JS_Parse_Error && + e.message === "SyntaxError: Legacy octal literals are not allowed in strict mode"; + } + for (var i = 0; i < inputs.length; i++) { + assert.throws(test(inputs[i]), error, inputs[i]); + } + }); +}); \ No newline at end of file diff --git a/test/mocha/string-literal.js b/test/mocha/string-literal.js index fc4c4277..eb9e6f1c 100644 --- a/test/mocha/string-literal.js +++ b/test/mocha/string-literal.js @@ -49,7 +49,7 @@ describe("String literals", function() { var error = function(e) { return e instanceof UglifyJS.JS_Parse_Error && - e.message === "SyntaxError: Octal literals are not allowed in strict mode"; + e.message === "SyntaxError: Legacy octal escape sequences are not allowed in strict mode"; } for (var input in inputs) { -- cgit v1.2.3