diff options
Diffstat (limited to 'test/mocha')
-rw-r--r-- | test/mocha/cli.js | 79 |
1 files changed, 77 insertions, 2 deletions
diff --git a/test/mocha/cli.js b/test/mocha/cli.js index 7162c816..697c09a3 100644 --- a/test/mocha/cli.js +++ b/test/mocha/cli.js @@ -296,14 +296,89 @@ describe("bin/uglifyjs", function () { assert.ok(err); assert.strictEqual(stdout, ""); assert.strictEqual(stderr.split(/\n/).slice(0, 4).join("\n"), [ - "Parse error at test/input/invalid/assign_3.js:1,18", + "Parse error at test/input/invalid/assign_3.js:1,17", "console.log(3 || ++this);", - " ^", + " ^", + "ERROR: Invalid use of ++ operator" + ].join("\n")); + done(); + }); + }); + it("Should throw syntax error (++null)", function(done) { + var command = uglifyjscmd + ' test/input/invalid/assign_4.js'; + + exec(command, function (err, stdout, stderr) { + assert.ok(err); + assert.strictEqual(stdout, ""); + assert.strictEqual(stderr.split(/\n/).slice(0, 4).join("\n"), [ + "Parse error at test/input/invalid/assign_4.js:1,0", + "++null", + "^", "ERROR: Invalid use of ++ operator" ].join("\n")); done(); }); }); + it("Should throw syntax error (a.=)", function(done) { + var command = uglifyjscmd + ' test/input/invalid/dot_1.js'; + + exec(command, function (err, stdout, stderr) { + assert.ok(err); + assert.strictEqual(stdout, ""); + assert.strictEqual(stderr.split(/\n/).slice(0, 4).join("\n"), [ + "Parse error at test/input/invalid/dot_1.js:1,2", + "a.=", + " ^", + "ERROR: Unexpected token: operator (=)" + ].join("\n")); + done(); + }); + }); + it("Should throw syntax error (%.a)", function(done) { + var command = uglifyjscmd + ' test/input/invalid/dot_2.js'; + + exec(command, function (err, stdout, stderr) { + assert.ok(err); + assert.strictEqual(stdout, ""); + assert.strictEqual(stderr.split(/\n/).slice(0, 4).join("\n"), [ + "Parse error at test/input/invalid/dot_2.js:1,0", + "%.a;", + "^", + "ERROR: Unexpected token: operator (%)" + ].join("\n")); + done(); + }); + }); + it("Should throw syntax error (a./();)", function(done) { + var command = uglifyjscmd + ' test/input/invalid/dot_3.js'; + + exec(command, function (err, stdout, stderr) { + assert.ok(err); + assert.strictEqual(stdout, ""); + assert.strictEqual(stderr.split(/\n/).slice(0, 4).join("\n"), [ + "Parse error at test/input/invalid/dot_3.js:1,2", + "a./();", + " ^", + "ERROR: Unexpected token: operator (/)" + ].join("\n")); + done(); + }); + }); + it("Should throw syntax error ({%: 1})", function(done) { + var command = uglifyjscmd + ' test/input/invalid/object.js'; + + exec(command, function (err, stdout, stderr) { + assert.ok(err); + assert.strictEqual(stdout, ""); + assert.strictEqual(stderr.split(/\n/).slice(0, 4).join("\n"), [ + "Parse error at test/input/invalid/object.js:1,13", + "console.log({%: 1});", + " ^", + "ERROR: Unexpected token: operator (%)" + ].join("\n")); + done(); + }); + }); it("Should handle literal string as source map input", function(done) { var command = [ uglifyjscmd, |