diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-05-08 07:05:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-08 07:05:19 +0800 |
commit | a3b2eb75bd57e78305c418242c538c41acf010e7 (patch) | |
tree | 7e6a0b12cd78089ce402067099612a34454c0b6c /test | |
parent | da295de82bfa9e1df39f45ee54e8e11ecce5dfb2 (diff) | |
download | tracifyjs-a3b2eb75bd57e78305c418242c538c41acf010e7.tar.gz tracifyjs-a3b2eb75bd57e78305c418242c538c41acf010e7.zip |
return `Error` from `minify()` (#1880)
Have `minify()` return `Error` in `result.error` rather than throwing it.
Diffstat (limited to 'test')
-rw-r--r-- | test/mocha/minify.js | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/test/mocha/minify.js b/test/mocha/minify.js index d69ef59c..7812fe6b 100644 --- a/test/mocha/minify.js +++ b/test/mocha/minify.js @@ -114,17 +114,18 @@ describe("minify", function() { } }); it("Should fail with multiple input and inline source map", function() { - assert.throws(function() { - Uglify.minify([ - read("./test/input/issue-520/input.js"), - read("./test/input/issue-520/output.js") - ], { - sourceMap: { - content: "inline", - url: "inline" - } - }); + var result = Uglify.minify([ + read("./test/input/issue-520/input.js"), + read("./test/input/issue-520/output.js") + ], { + sourceMap: { + content: "inline", + url: "inline" + } }); + var err = result.error; + assert.ok(err instanceof Error); + assert.strictEqual(err.stack.split(/\n/)[0], "Error: inline source map only works with singular input"); }); }); @@ -170,17 +171,14 @@ describe("minify", function() { }); describe("JS_Parse_Error", function() { - it("should throw syntax error", function() { - assert.throws(function() { - Uglify.minify("function f(a{}"); - }, function(err) { - assert.ok(err instanceof Error); - assert.strictEqual(err.stack.split(/\n/)[0], "SyntaxError: Unexpected token punc «{», expected punc «,»"); - assert.strictEqual(err.filename, "0"); - assert.strictEqual(err.line, 1); - assert.strictEqual(err.col, 12); - return true; - }); + it("should return syntax error", function() { + var result = Uglify.minify("function f(a{}"); + var err = result.error; + assert.ok(err instanceof Error); + assert.strictEqual(err.stack.split(/\n/)[0], "SyntaxError: Unexpected token punc «{», expected punc «,»"); + assert.strictEqual(err.filename, "0"); + assert.strictEqual(err.line, 1); + assert.strictEqual(err.col, 12); }); }); }); |