aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/cli.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/mocha/cli.js')
-rw-r--r--test/mocha/cli.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/mocha/cli.js b/test/mocha/cli.js
index b54044eb..4c4943c6 100644
--- a/test/mocha/cli.js
+++ b/test/mocha/cli.js
@@ -518,6 +518,36 @@ describe("bin/uglifyjs", function () {
done();
});
});
+ it("Should throw syntax error (for-in init)", function(done) {
+ var command = uglifyjscmd + ' test/input/invalid/for-in_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/for-in_1.js:2,5",
+ "for (1, 2, a in b) {",
+ " ^",
+ "ERROR: Invalid left-hand side in for..in loop"
+ ].join("\n"));
+ done();
+ });
+ });
+ it("Should throw syntax error (for-in var)", function(done) {
+ var command = uglifyjscmd + ' test/input/invalid/for-in_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/for-in_2.js:2,5",
+ "for (var a, b in c) {",
+ " ^",
+ "ERROR: Only one variable declaration allowed in for..in loop"
+ ].join("\n"));
+ done();
+ });
+ });
it("Should handle literal string as source map input", function(done) {
var command = [
uglifyjscmd,