From bb9c9707aa6b4c625ad985798aea879080411ce1 Mon Sep 17 00:00:00 2001 From: Anthony Van de Gejuchte Date: Sun, 12 Jun 2016 18:58:20 +0200 Subject: Don't allow with statements in strict mode --- test/mocha/with.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/mocha/with.js (limited to 'test/mocha/with.js') diff --git a/test/mocha/with.js b/test/mocha/with.js new file mode 100644 index 00000000..d284f1c2 --- /dev/null +++ b/test/mocha/with.js @@ -0,0 +1,16 @@ +var assert = require("assert"); +var uglify = require("../../"); + +describe("With", function() { + it ("Should throw syntaxError when using with statement in strict mode", function() { + var code = '"use strict";\nthrow NotEarlyError;\nwith ({}) { }'; + var test = function() { + uglify.parse(code); + } + var error = function(e) { + return e instanceof uglify.JS_Parse_Error && + e.message === "Strict mode may not include a with statement"; + } + assert.throws(test, error); + }); +}); \ No newline at end of file -- cgit v1.2.3