});
});
it("Should fail with invalid syntax", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/simple.js';
+ var command = uglifyjscmd + " test/input/invalid/simple.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
var lines = stderr.split(/\n/);
});
});
it("Should fail with correct marking of tabs", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/tab.js';
+ var command = uglifyjscmd + " test/input/invalid/tab.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
var lines = stderr.split(/\n/);
});
});
it("Should fail with correct marking at start of line", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/eof.js';
+ var command = uglifyjscmd + " test/input/invalid/eof.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
var lines = stderr.split(/\n/);
});
});
it("Should fail with a missing loop body", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/loop-no-body.js';
+ var command = uglifyjscmd + " test/input/invalid/loop-no-body.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
var lines = stderr.split(/\n/);
});
});
it("Should throw syntax error (5--)", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/assign_1.js';
+ var command = uglifyjscmd + " test/input/invalid/assign_1.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error (Math.random() /= 2)", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/assign_2.js';
+ var command = uglifyjscmd + " test/input/invalid/assign_2.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error (++this)", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/assign_3.js';
+ var command = uglifyjscmd + " test/input/invalid/assign_3.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error (++null)", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/assign_4.js';
+ var command = uglifyjscmd + " test/input/invalid/assign_4.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error (a.=)", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/dot_1.js';
+ var command = uglifyjscmd + " test/input/invalid/dot_1.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error (%.a)", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/dot_2.js';
+ var command = uglifyjscmd + " test/input/invalid/dot_2.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error (a./();)", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/dot_3.js';
+ var command = uglifyjscmd + " test/input/invalid/dot_3.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error ({%: 1})", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/object.js';
+ var command = uglifyjscmd + " test/input/invalid/object.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error (delete x)", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/delete.js';
+ var command = uglifyjscmd + " test/input/invalid/delete.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error (function g(arguments))", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/function_1.js';
+ var command = uglifyjscmd + " test/input/invalid/function_1.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error (function eval())", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/function_2.js';
+ var command = uglifyjscmd + " test/input/invalid/function_2.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error (iife arguments())", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/function_3.js';
+ var command = uglifyjscmd + " test/input/invalid/function_3.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error (catch (eval))", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/try.js';
+ var command = uglifyjscmd + " test/input/invalid/try.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error (var eval)", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/var.js';
+ var command = uglifyjscmd + " test/input/invalid/var.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error (else)", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/else.js';
+ var command = uglifyjscmd + " test/input/invalid/else.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error (return)", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/return.js';
+ var command = uglifyjscmd + " test/input/invalid/return.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error (for-in init)", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/for-in_1.js';
+ var command = uglifyjscmd + " test/input/invalid/for-in_1.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
});
});
it("Should throw syntax error (for-in var)", function(done) {
- var command = uglifyjscmd + ' test/input/invalid/for-in_2.js';
+ var command = uglifyjscmd + " test/input/invalid/for-in_2.js";
exec(command, function(err, stdout, stderr) {
assert.ok(err);
assert.strictEqual(stdout, "");
done();
});
});
+ it("Should throw syntax error (switch defaults)", function(done) {
+ var command = uglifyjscmd + " test/input/invalid/switch.js";
+ exec(command, function(err, stdout, stderr) {
+ assert.ok(err);
+ var lines = stderr.split(/\n/);
+ assert.strictEqual(lines[0], "Parse error at test/input/invalid/switch.js:3,2");
+ assert.strictEqual(lines[1], " default:");
+ assert.strictEqual(lines[2], " ^");
+ assert.strictEqual(lines[3], "ERROR: More than one default clause in switch statement");
+ done();
+ });
+ });
it("Should handle literal string as source map input", function(done) {
var command = [
uglifyjscmd,