diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-04-19 04:27:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-19 04:27:13 +0800 |
commit | b4b9305db0d3c4682848ed0a4214f1fee332a078 (patch) | |
tree | 487db01afdbe5d9b00225d22ea599cbbf46b6489 /test | |
parent | 28cfb65c47e7a2adeec35d8a78dd8bb0cf06af12 (diff) | |
download | tracifyjs-b4b9305db0d3c4682848ed0a4214f1fee332a078.tar.gz tracifyjs-b4b9305db0d3c4682848ed0a4214f1fee332a078.zip |
fix parser bugs & CLI reporting (#1827)
fixes #1825
Diffstat (limited to 'test')
-rw-r--r-- | test/input/invalid/assign_4.js | 1 | ||||
-rw-r--r-- | test/input/invalid/dot_1.js | 1 | ||||
-rw-r--r-- | test/input/invalid/dot_2.js | 1 | ||||
-rw-r--r-- | test/input/invalid/dot_3.js | 1 | ||||
-rw-r--r-- | test/input/invalid/object.js | 1 | ||||
-rw-r--r-- | test/mocha/cli.js | 79 |
6 files changed, 82 insertions, 2 deletions
diff --git a/test/input/invalid/assign_4.js b/test/input/invalid/assign_4.js new file mode 100644 index 00000000..d4d6b113 --- /dev/null +++ b/test/input/invalid/assign_4.js @@ -0,0 +1 @@ +++null diff --git a/test/input/invalid/dot_1.js b/test/input/invalid/dot_1.js new file mode 100644 index 00000000..7c4f3a66 --- /dev/null +++ b/test/input/invalid/dot_1.js @@ -0,0 +1 @@ +a.= diff --git a/test/input/invalid/dot_2.js b/test/input/invalid/dot_2.js new file mode 100644 index 00000000..32c027f8 --- /dev/null +++ b/test/input/invalid/dot_2.js @@ -0,0 +1 @@ +%.a; diff --git a/test/input/invalid/dot_3.js b/test/input/invalid/dot_3.js new file mode 100644 index 00000000..65573828 --- /dev/null +++ b/test/input/invalid/dot_3.js @@ -0,0 +1 @@ +a./(); diff --git a/test/input/invalid/object.js b/test/input/invalid/object.js new file mode 100644 index 00000000..46216d81 --- /dev/null +++ b/test/input/invalid/object.js @@ -0,0 +1 @@ +console.log({%: 1}); 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, |