aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/benchmark.js10
-rw-r--r--test/compress/ascii.js5
-rw-r--r--test/compress/issue-1321.js6
-rw-r--r--test/compress/issue-1446.js2
-rw-r--r--test/compress/issue-1588.js8
-rw-r--r--test/compress/issue-1704.js64
-rw-r--r--test/compress/issue-1733.js8
-rw-r--r--test/compress/loops.js16
-rw-r--r--test/compress/properties.js12
-rw-r--r--test/compress/screw-ie8.js72
-rw-r--r--test/jetstream.js2
-rw-r--r--test/mocha/cli.js89
-rw-r--r--test/mocha/comment-filter.js2
-rw-r--r--test/mocha/comment.js4
-rw-r--r--test/mocha/comment_before_constant.js5
-rw-r--r--test/mocha/directives.js10
-rw-r--r--test/mocha/glob.js108
-rw-r--r--test/mocha/huge-number-of-comments.js7
-rw-r--r--test/mocha/input-sourcemaps.js6
-rw-r--r--test/mocha/let.js2
-rw-r--r--test/mocha/line-endings.js3
-rw-r--r--test/mocha/minify-file-map.js30
-rw-r--r--test/mocha/minify.js80
-rw-r--r--test/mocha/new.js2
-rw-r--r--test/mocha/release.js4
-rw-r--r--test/mocha/screw-ie8.js4
-rw-r--r--test/mocha/spidermonkey.js8
-rw-r--r--test/ufuzz.js10
-rw-r--r--test/ufuzz.json15
29 files changed, 315 insertions, 279 deletions
diff --git a/test/benchmark.js b/test/benchmark.js
index c150e5cf..c67a8548 100644
--- a/test/benchmark.js
+++ b/test/benchmark.js
@@ -7,7 +7,7 @@ var createHash = require("crypto").createHash;
var fork = require("child_process").fork;
var args = process.argv.slice(2);
if (!args.length) {
- args.push("-mc", "warnings=false");
+ args.push("-mc");
}
args.push("--stats");
var urls = [
@@ -29,11 +29,11 @@ function done() {
var info = results[url];
console.log();
console.log(url);
- console.log(info.log);
var elapsed = 0;
- info.log.replace(/: ([0-9]+\.[0-9]{3})s/g, function(match, time) {
- elapsed += parseFloat(time);
- });
+ console.log(info.log.replace(/Elapsed: ([0-9]+)\s*/g, function(match, time) {
+ elapsed += 1e-3 * parseInt(time);
+ return "";
+ }));
console.log("Run-time:", elapsed.toFixed(3), "s");
console.log("Original:", info.input, "bytes");
console.log("Uglified:", info.output, "bytes");
diff --git a/test/compress/ascii.js b/test/compress/ascii.js
index 2232d263..9662d413 100644
--- a/test/compress/ascii.js
+++ b/test/compress/ascii.js
@@ -2,7 +2,7 @@ ascii_only_true: {
options = {}
beautify = {
ascii_only : true,
- screw_ie8 : true,
+ ie8 : false,
beautify : false,
}
input: {
@@ -20,7 +20,7 @@ ascii_only_false: {
options = {}
beautify = {
ascii_only : false,
- screw_ie8 : true,
+ ie8 : false,
beautify : false,
}
input: {
@@ -33,4 +33,3 @@ ascii_only_false: {
}
expect_exact: 'function f(){return"\\x000\\x001\\x007\\08\\0"+"\\0\x01\x02\x03\x04\x05\x06\x07\\b\\t\\n\\v\\f\\r\x0e\x0f"+"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"+\' !"# ... }~\x7f\x80\x81 ... \xfe\xff\u0fff\uffff\'}'
}
-
diff --git a/test/compress/issue-1321.js b/test/compress/issue-1321.js
index 7449d3e2..dcbfde64 100644
--- a/test/compress/issue-1321.js
+++ b/test/compress/issue-1321.js
@@ -1,6 +1,6 @@
issue_1321_no_debug: {
mangle_props = {
- ignore_quoted: true
+ keep_quoted: true
}
input: {
var x = {};
@@ -19,7 +19,7 @@ issue_1321_no_debug: {
issue_1321_debug: {
mangle_props = {
- ignore_quoted: true,
+ keep_quoted: true,
debug: ""
}
input: {
@@ -39,7 +39,7 @@ issue_1321_debug: {
issue_1321_with_quoted: {
mangle_props = {
- ignore_quoted: false
+ keep_quoted: false
}
input: {
var x = {};
diff --git a/test/compress/issue-1446.js b/test/compress/issue-1446.js
index 3d69aa09..cad1ae57 100644
--- a/test/compress/issue-1446.js
+++ b/test/compress/issue-1446.js
@@ -23,7 +23,7 @@ typeof_eq_undefined: {
typeof_eq_undefined_ie8: {
options = {
comparisons: true,
- screw_ie8: false
+ ie8: true,
}
input: {
var a = typeof b != "undefined";
diff --git a/test/compress/issue-1588.js b/test/compress/issue-1588.js
index fce9ba54..4e20a21d 100644
--- a/test/compress/issue-1588.js
+++ b/test/compress/issue-1588.js
@@ -1,9 +1,9 @@
screw_ie8: {
options = {
- screw_ie8: true,
+ ie8: false,
}
mangle = {
- screw_ie8: true,
+ ie8: false,
}
input: {
try { throw "foo"; } catch (x) { console.log(x); }
@@ -16,10 +16,10 @@ screw_ie8: {
support_ie8: {
options = {
- screw_ie8: false,
+ ie8: true,
}
mangle = {
- screw_ie8: false,
+ ie8: true,
}
input: {
try { throw "foo"; } catch (x) { console.log(x); }
diff --git a/test/compress/issue-1704.js b/test/compress/issue-1704.js
index a73f7f99..25e49522 100644
--- a/test/compress/issue-1704.js
+++ b/test/compress/issue-1704.js
@@ -1,10 +1,10 @@
mangle_catch: {
options = {
- screw_ie8: true,
+ ie8: false,
toplevel: false,
}
mangle = {
- screw_ie8: true,
+ ie8: false,
toplevel: false,
}
input: {
@@ -22,11 +22,11 @@ mangle_catch: {
mangle_catch_ie8: {
options = {
- screw_ie8: false,
+ ie8: true,
toplevel: false,
}
mangle = {
- screw_ie8: false,
+ ie8: true,
toplevel: false,
}
input: {
@@ -44,11 +44,11 @@ mangle_catch_ie8: {
mangle_catch_var: {
options = {
- screw_ie8: true,
+ ie8: false,
toplevel: false,
}
mangle = {
- screw_ie8: true,
+ ie8: false,
toplevel: false,
}
input: {
@@ -66,11 +66,11 @@ mangle_catch_var: {
mangle_catch_var_ie8: {
options = {
- screw_ie8: false,
+ ie8: true,
toplevel: false,
}
mangle = {
- screw_ie8: false,
+ ie8: true,
toplevel: false,
}
input: {
@@ -88,11 +88,11 @@ mangle_catch_var_ie8: {
mangle_catch_toplevel: {
options = {
- screw_ie8: true,
+ ie8: false,
toplevel: true,
}
mangle = {
- screw_ie8: true,
+ ie8: false,
toplevel: true,
}
input: {
@@ -110,11 +110,11 @@ mangle_catch_toplevel: {
mangle_catch_ie8_toplevel: {
options = {
- screw_ie8: false,
+ ie8: true,
toplevel: true,
}
mangle = {
- screw_ie8: false,
+ ie8: true,
toplevel: true,
}
input: {
@@ -132,11 +132,11 @@ mangle_catch_ie8_toplevel: {
mangle_catch_var_toplevel: {
options = {
- screw_ie8: true,
+ ie8: false,
toplevel: true,
}
mangle = {
- screw_ie8: true,
+ ie8: false,
toplevel: true,
}
input: {
@@ -154,11 +154,11 @@ mangle_catch_var_toplevel: {
mangle_catch_var_ie8_toplevel: {
options = {
- screw_ie8: false,
+ ie8: true,
toplevel: true,
}
mangle = {
- screw_ie8: false,
+ ie8: true,
toplevel: true,
}
input: {
@@ -176,11 +176,11 @@ mangle_catch_var_ie8_toplevel: {
mangle_catch_redef_1: {
options = {
- screw_ie8: true,
+ ie8: false,
toplevel: false,
}
mangle = {
- screw_ie8: true,
+ ie8: false,
toplevel: false,
}
input: {
@@ -198,11 +198,11 @@ mangle_catch_redef_1: {
mangle_catch_redef_1_ie8: {
options = {
- screw_ie8: false,
+ ie8: true,
toplevel: false,
}
mangle = {
- screw_ie8: false,
+ ie8: true,
toplevel: false,
}
input: {
@@ -220,11 +220,11 @@ mangle_catch_redef_1_ie8: {
mangle_catch_redef_1_toplevel: {
options = {
- screw_ie8: true,
+ ie8: false,
toplevel: true,
}
mangle = {
- screw_ie8: true,
+ ie8: false,
toplevel: true,
}
input: {
@@ -242,11 +242,11 @@ mangle_catch_redef_1_toplevel: {
mangle_catch_redef_1_ie8_toplevel: {
options = {
- screw_ie8: false,
+ ie8: true,
toplevel: true,
}
mangle = {
- screw_ie8: false,
+ ie8: true,
toplevel: true,
}
input: {
@@ -264,11 +264,11 @@ mangle_catch_redef_1_ie8_toplevel: {
mangle_catch_redef_2: {
options = {
- screw_ie8: true,
+ ie8: false,
toplevel: false,
}
mangle = {
- screw_ie8: true,
+ ie8: false,
toplevel: false,
}
input: {
@@ -285,11 +285,11 @@ mangle_catch_redef_2: {
mangle_catch_redef_2_ie8: {
options = {
- screw_ie8: false,
+ ie8: true,
toplevel: false,
}
mangle = {
- screw_ie8: false,
+ ie8: true,
toplevel: false,
}
input: {
@@ -306,11 +306,11 @@ mangle_catch_redef_2_ie8: {
mangle_catch_redef_2_toplevel: {
options = {
- screw_ie8: true,
+ ie8: false,
toplevel: true,
}
mangle = {
- screw_ie8: true,
+ ie8: false,
toplevel: true,
}
input: {
@@ -327,11 +327,11 @@ mangle_catch_redef_2_toplevel: {
mangle_catch_redef_2_ie8_toplevel: {
options = {
- screw_ie8: false,
+ ie8: true,
toplevel: true,
}
mangle = {
- screw_ie8: false,
+ ie8: true,
toplevel: true,
}
input: {
diff --git a/test/compress/issue-1733.js b/test/compress/issue-1733.js
index 3a940c96..f1e576c7 100644
--- a/test/compress/issue-1733.js
+++ b/test/compress/issue-1733.js
@@ -1,6 +1,6 @@
function_iife_catch: {
mangle = {
- screw_ie8: true,
+ ie8: false,
}
input: {
function f(n) {
@@ -21,7 +21,7 @@ function_iife_catch: {
function_iife_catch_ie8: {
mangle = {
- screw_ie8: false,
+ ie8: true,
}
input: {
function f(n) {
@@ -42,7 +42,7 @@ function_iife_catch_ie8: {
function_catch_catch: {
mangle = {
- screw_ie8: true,
+ ie8: false,
}
input: {
var o = 0;
@@ -70,7 +70,7 @@ function_catch_catch: {
function_catch_catch_ie8: {
mangle = {
- screw_ie8: false,
+ ie8: true,
}
input: {
var o = 0;
diff --git a/test/compress/loops.js b/test/compress/loops.js
index f13f5cc5..4d354bcf 100644
--- a/test/compress/loops.js
+++ b/test/compress/loops.js
@@ -245,7 +245,7 @@ issue_1532: {
issue_186: {
beautify = {
beautify: false,
- screw_ie8: true,
+ ie8: false,
}
input: {
var x = 3;
@@ -264,7 +264,7 @@ issue_186: {
issue_186_ie8: {
beautify = {
beautify: false,
- screw_ie8: false,
+ ie8: true,
}
input: {
var x = 3;
@@ -283,7 +283,7 @@ issue_186_ie8: {
issue_186_beautify: {
beautify = {
beautify: true,
- screw_ie8: true,
+ ie8: false,
}
input: {
var x = 3;
@@ -310,7 +310,7 @@ issue_186_beautify: {
issue_186_beautify_ie8: {
beautify = {
beautify: true,
- screw_ie8: false,
+ ie8: true,
}
input: {
var x = 3;
@@ -340,7 +340,7 @@ issue_186_bracketize: {
beautify = {
beautify: false,
bracketize: true,
- screw_ie8: true,
+ ie8: false,
}
input: {
var x = 3;
@@ -360,7 +360,7 @@ issue_186_bracketize_ie8: {
beautify = {
beautify: false,
bracketize: true,
- screw_ie8: false,
+ ie8: true,
}
input: {
var x = 3;
@@ -380,7 +380,7 @@ issue_186_beautify_bracketize: {
beautify = {
beautify: true,
bracketize: true,
- screw_ie8: true,
+ ie8: false,
}
input: {
var x = 3;
@@ -412,7 +412,7 @@ issue_186_beautify_bracketize_ie8: {
beautify = {
beautify: true,
bracketize: true,
- screw_ie8: false,
+ ie8: true,
}
input: {
var x = 3;
diff --git a/test/compress/properties.js b/test/compress/properties.js
index 29bdfe2a..3e06dc1e 100644
--- a/test/compress/properties.js
+++ b/test/compress/properties.js
@@ -13,7 +13,7 @@ keep_properties: {
dot_properties: {
options = {
properties: true,
- screw_ie8: false
+ ie8: true,
};
input: {
a["foo"] = "bar";
@@ -36,7 +36,7 @@ dot_properties: {
dot_properties_es5: {
options = {
properties: true,
- screw_ie8: true
+ ie8: false,
};
input: {
a["foo"] = "bar";
@@ -125,7 +125,7 @@ evaluate_string_length: {
mangle_properties: {
mangle_props = {
- ignore_quoted: false
+ keep_quoted: false
};
input: {
a["foo"] = "bar";
@@ -148,7 +148,7 @@ mangle_unquoted_properties: {
properties: false
}
mangle_props = {
- ignore_quoted: true
+ keep_quoted: true
}
beautify = {
beautify: false,
@@ -233,12 +233,12 @@ mangle_debug_suffix: {
}
}
-mangle_debug_suffix_ignore_quoted: {
+mangle_debug_suffix_keep_quoted: {
options = {
properties: false
}
mangle_props = {
- ignore_quoted: true,
+ keep_quoted: true,
debug: "XYZ",
reserved: []
}
diff --git a/test/compress/screw-ie8.js b/test/compress/screw-ie8.js
index 68d1a364..a9fbeb51 100644
--- a/test/compress/screw-ie8.js
+++ b/test/compress/screw-ie8.js
@@ -1,9 +1,9 @@
do_screw: {
options = {
- screw_ie8: true,
+ ie8: false,
}
beautify = {
- screw_ie8: true,
+ ie8: false,
ascii_only: true,
}
input: {
@@ -14,10 +14,10 @@ do_screw: {
dont_screw: {
options = {
- screw_ie8: false,
+ ie8: true,
}
beautify = {
- screw_ie8: false,
+ ie8: true,
ascii_only: true,
}
input: {
@@ -28,7 +28,7 @@ dont_screw: {
do_screw_constants: {
options = {
- screw_ie8: true,
+ ie8: false,
}
input: {
f(undefined, Infinity);
@@ -38,7 +38,7 @@ do_screw_constants: {
dont_screw_constants: {
options = {
- screw_ie8: false,
+ ie8: true,
}
input: {
f(undefined, Infinity);
@@ -47,9 +47,15 @@ dont_screw_constants: {
}
do_screw_try_catch: {
- options = { screw_ie8: true };
- mangle = { screw_ie8: true };
- beautify = { screw_ie8: true };
+ options = {
+ ie8: false,
+ }
+ mangle = {
+ ie8: false,
+ }
+ beautify = {
+ ie8: false,
+ }
input: {
good = function(e){
return function(error){
@@ -75,9 +81,15 @@ do_screw_try_catch: {
}
dont_screw_try_catch: {
- options = { screw_ie8: false };
- mangle = { screw_ie8: false };
- beautify = { screw_ie8: false };
+ options = {
+ ie8: true,
+ }
+ mangle = {
+ ie8: true,
+ }
+ beautify = {
+ ie8: true,
+ }
input: {
bad = function(e){
return function(error){
@@ -103,9 +115,15 @@ dont_screw_try_catch: {
}
do_screw_try_catch_undefined: {
- options = { screw_ie8: true };
- mangle = { screw_ie8: true };
- beautify = { screw_ie8: true };
+ options = {
+ ie8: false,
+ }
+ mangle = {
+ ie8: false,
+ }
+ beautify = {
+ ie8: false,
+ }
input: {
function a(b){
try {
@@ -132,9 +150,15 @@ do_screw_try_catch_undefined: {
}
dont_screw_try_catch_undefined: {
- options = { screw_ie8: false };
- mangle = { screw_ie8: false };
- beautify = { screw_ie8: false };
+ options = {
+ ie8: true,
+ }
+ mangle = {
+ ie8: true,
+ }
+ beautify = {
+ ie8: true,
+ }
input: {
function a(b){
try {
@@ -164,11 +188,11 @@ reduce_vars: {
options = {
evaluate: true,
reduce_vars: true,
- screw_ie8: false,
+ ie8: true,
unused: true,
}
mangle = {
- screw_ie8: false,
+ ie8: true,
}
input: {
function f() {
@@ -196,10 +220,10 @@ reduce_vars: {
issue_1586_1: {
options = {
- screw_ie8: false,
+ ie8: true,
}
mangle = {
- screw_ie8: false,
+ ie8: true,
}
input: {
function f() {
@@ -215,10 +239,10 @@ issue_1586_1: {
issue_1586_2: {
options = {
- screw_ie8: true,
+ ie8: false,
}
mangle = {
- screw_ie8: true,
+ ie8: false,
}
input: {
function f() {
diff --git a/test/jetstream.js b/test/jetstream.js
index a8195389..56da7ad8 100644
--- a/test/jetstream.js
+++ b/test/jetstream.js
@@ -12,7 +12,7 @@ if (typeof phantom == "undefined") {
});
var args = process.argv.slice(2);
if (!args.length) {
- args.push("-mc", "warnings=false");
+ args.push("-mc");
}
args.push("--stats");
var child_process = require("child_process");
diff --git a/test/mocha/cli.js b/test/mocha/cli.js
index b956309a..7162c816 100644
--- a/test/mocha/cli.js
+++ b/test/mocha/cli.js
@@ -2,6 +2,10 @@ var assert = require("assert");
var exec = require("child_process").exec;
var readFileSync = require("fs").readFileSync;
+function read(path) {
+ return readFileSync(path, "utf8");
+}
+
describe("bin/uglifyjs", function () {
var uglifyjscmd = '"' + process.argv[0] + '" bin/uglifyjs';
it("should produce a functional build when using --self", function (done) {
@@ -20,7 +24,7 @@ describe("bin/uglifyjs", function () {
done();
});
});
- it("Should be able to filter comments correctly with `--comment all`", function (done) {
+ it("Should be able to filter comments correctly with `--comments all`", function (done) {
var command = uglifyjscmd + ' test/input/comments/filter.js --comments all';
exec(command, function (err, stdout) {
@@ -50,8 +54,8 @@ describe("bin/uglifyjs", function () {
done();
});
});
- it("Should append source map to output when using --source-map-inline", function (done) {
- var command = uglifyjscmd + ' test/input/issue-1323/sample.js --source-map-inline';
+ it("Should append source map to output when using --source-map url=inline", function (done) {
+ var command = uglifyjscmd + " test/input/issue-1323/sample.js --source-map url=inline";
exec(command, function (err, stdout) {
if (err) throw err;
@@ -61,7 +65,7 @@ describe("bin/uglifyjs", function () {
done();
});
});
- it("should not append source map to output when not using --source-map-inline", function (done) {
+ it("should not append source map to output when not using --source-map url=inline", function (done) {
var command = uglifyjscmd + ' test/input/issue-1323/sample.js';
exec(command, function (err, stdout) {
@@ -137,7 +141,7 @@ describe("bin/uglifyjs", function () {
exec(command, function (err, stdout) {
if (err) throw err;
- assert.strictEqual(stdout, readFileSync("test/input/issue-1482/default.js", "utf8"));
+ assert.strictEqual(stdout, read("test/input/issue-1482/default.js"));
done();
});
});
@@ -147,55 +151,59 @@ describe("bin/uglifyjs", function () {
exec(command, function (err, stdout) {
if (err) throw err;
- assert.strictEqual(stdout, readFileSync("test/input/issue-1482/bracketize.js", "utf8"));
+ assert.strictEqual(stdout, read("test/input/issue-1482/bracketize.js"));
done();
});
});
it("Should process inline source map", function(done) {
- var command = uglifyjscmd + ' test/input/issue-520/input.js -mc toplevel --in-source-map inline --source-map-inline';
+ var command = uglifyjscmd + " test/input/issue-520/input.js -mc toplevel --source-map content=inline,url=inline";
exec(command, function (err, stdout) {
if (err) throw err;
- assert.strictEqual(stdout, readFileSync("test/input/issue-520/output.js", "utf8"));
+ assert.strictEqual(stdout, read("test/input/issue-520/output.js"));
done();
});
});
it("Should warn for missing inline source map", function(done) {
- var command = uglifyjscmd + ' test/input/issue-1323/sample.js --in-source-map inline';
+ var command = uglifyjscmd + " test/input/issue-1323/sample.js --source-map content=inline,url=inline";
exec(command, function (err, stdout, stderr) {
if (err) throw err;
- assert.strictEqual(stdout, "var bar=function(){function foo(bar){return bar}return foo}();\n");
+ assert.strictEqual(stdout, [
+ "var bar=function(){function foo(bar){return bar}return foo}();",
+ "//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QvaW5wdXQvaXNzdWUtMTMyMy9zYW1wbGUuanMiXSwibmFtZXMiOlsiYmFyIiwiZm9vIl0sIm1hcHBpbmdzIjoiQUFBQSxHQUFJQSxLQUFNLFdBQ04sUUFBU0MsS0FBS0QsS0FDVixNQUFPQSxLQUdYLE1BQU9DIn0=",
+ "",
+ ].join("\n"));
assert.strictEqual(stderr, "WARN: inline source map not found\n");
done();
});
});
it("Should fail with multiple input and inline source map", function(done) {
- var command = uglifyjscmd + ' test/input/issue-520/input.js test/input/issue-520/output.js --in-source-map inline --source-map-inline';
+ var command = uglifyjscmd + " test/input/issue-520/input.js test/input/issue-520/output.js --source-map content=inline,url=inline";
exec(command, function (err, stdout, stderr) {
assert.ok(err);
- assert.strictEqual(stderr, "ERROR: Inline source map only works with singular input\n");
+ assert.strictEqual(stderr, "ERROR: inline source map only works with singular input\n");
done();
});
});
it("Should fail with acorn and inline source map", function(done) {
- var command = uglifyjscmd + ' test/input/issue-520/input.js --in-source-map inline --source-map-inline --acorn';
+ var command = uglifyjscmd + " test/input/issue-520/input.js --source-map content=inline,url=inline -p acorn";
exec(command, function (err, stdout, stderr) {
assert.ok(err);
- assert.strictEqual(stderr, "ERROR: Inline source map only works with built-in parser\n");
+ assert.strictEqual(stderr, "ERROR: inline source map only works with built-in parser\n");
done();
});
});
it("Should fail with SpiderMonkey and inline source map", function(done) {
- var command = uglifyjscmd + ' test/input/issue-520/input.js --in-source-map inline --source-map-inline --spidermonkey';
+ var command = uglifyjscmd + " test/input/issue-520/input.js --source-map content=inline,url=inline -p spidermonkey";
exec(command, function (err, stdout, stderr) {
assert.ok(err);
- assert.strictEqual(stderr, "ERROR: Inline source map only works with built-in parser\n");
+ assert.strictEqual(stderr, "ERROR: inline source map only works with built-in parser\n");
done();
});
});
@@ -208,7 +216,7 @@ describe("bin/uglifyjs", function () {
assert.strictEqual(lines[0], "Parse error at test/input/invalid/simple.js:1,12");
assert.strictEqual(lines[1], "function f(a{}");
assert.strictEqual(lines[2], " ^");
- assert.strictEqual(lines[3], "SyntaxError: Unexpected token punc «{», expected punc «,»");
+ assert.strictEqual(lines[3], "ERROR: Unexpected token punc «{», expected punc «,»");
done();
});
});
@@ -221,7 +229,7 @@ describe("bin/uglifyjs", function () {
assert.strictEqual(lines[0], "Parse error at test/input/invalid/tab.js:1,12");
assert.strictEqual(lines[1], "\t\tfoo(\txyz, 0abc);");
assert.strictEqual(lines[2], "\t\t \t ^");
- assert.strictEqual(lines[3], "SyntaxError: Invalid syntax: 0abc");
+ assert.strictEqual(lines[3], "ERROR: Invalid syntax: 0abc");
done();
});
});
@@ -234,7 +242,7 @@ describe("bin/uglifyjs", function () {
assert.strictEqual(lines[0], "Parse error at test/input/invalid/eof.js:2,0");
assert.strictEqual(lines[1], "foo, bar(");
assert.strictEqual(lines[2], " ^");
- assert.strictEqual(lines[3], "SyntaxError: Unexpected token: eof (undefined)");
+ assert.strictEqual(lines[3], "ERROR: Unexpected token: eof (undefined)");
done();
});
});
@@ -247,20 +255,10 @@ describe("bin/uglifyjs", function () {
assert.strictEqual(lines[0], "Parse error at test/input/invalid/loop-no-body.js:2,0");
assert.strictEqual(lines[1], "for (var i = 0; i < 1; i++) ");
assert.strictEqual(lines[2], " ^");
- assert.strictEqual(lines[3], "SyntaxError: Unexpected token: eof (undefined)");
+ assert.strictEqual(lines[3], "ERROR: Unexpected token: eof (undefined)");
done();
});
});
- it("Should support hyphen as shorthand", function(done) {
- var command = uglifyjscmd + ' test/input/issue-1431/sample.js -m keep-fnames=true';
-
- exec(command, function (err, stdout) {
- if (err) throw err;
-
- assert.strictEqual(stdout, "function f(r){return function(){function n(n){return n*n}return r(n)}}function g(n){return n(1)+n(2)}console.log(f(g)()==5);\n");
- done();
- });
- });
it("Should throw syntax error (5--)", function(done) {
var command = uglifyjscmd + ' test/input/invalid/assign_1.js';
@@ -271,7 +269,7 @@ describe("bin/uglifyjs", function () {
"Parse error at test/input/invalid/assign_1.js:1,18",
"console.log(1 || 5--);",
" ^",
- "SyntaxError: Invalid use of -- operator"
+ "ERROR: Invalid use of -- operator"
].join("\n"));
done();
});
@@ -286,7 +284,7 @@ describe("bin/uglifyjs", function () {
"Parse error at test/input/invalid/assign_2.js:1,32",
"console.log(2 || (Math.random() /= 2));",
" ^",
- "SyntaxError: Invalid assignment"
+ "ERROR: Invalid assignment"
].join("\n"));
done();
});
@@ -301,9 +299,34 @@ describe("bin/uglifyjs", function () {
"Parse error at test/input/invalid/assign_3.js:1,18",
"console.log(3 || ++this);",
" ^",
- "SyntaxError: Invalid use of ++ operator"
+ "ERROR: Invalid use of ++ operator"
].join("\n"));
done();
});
});
+ it("Should handle literal string as source map input", function(done) {
+ var command = [
+ uglifyjscmd,
+ "test/input/issue-1236/simple.js",
+ "--source-map",
+ 'content="' + read_map() + '",url=inline'
+ ].join(" ");
+
+ exec(command, function (err, stdout) {
+ if (err) throw err;
+
+ assert.strictEqual(stdout, [
+ '"use strict";var foo=function foo(x){return"foo "+x};console.log(foo("bar"));',
+ "//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LmpzIl0sIm5hbWVzIjpbImZvbyIsIngiLCJjb25zb2xlIiwibG9nIl0sIm1hcHBpbmdzIjoiWUFBQSxJQUFJQSxLQUFNLFFBQU5BLEtBQU1DLEdBQUEsTUFBSyxPQUFTQSxFQUN4QkMsU0FBUUMsSUFBSUgsSUFBSSJ9",
+ ""
+ ].join("\n"));
+ done();
+ });
+
+ function read_map() {
+ var map = JSON.parse(read("./test/input/issue-1236/simple.js.map"));
+ delete map.sourcesContent;
+ return JSON.stringify(map).replace(/"/g, '\\"');
+ }
+ });
});
diff --git a/test/mocha/comment-filter.js b/test/mocha/comment-filter.js
index ec17aa8c..4b74ebf9 100644
--- a/test/mocha/comment-filter.js
+++ b/test/mocha/comment-filter.js
@@ -75,7 +75,6 @@ describe("comment filters", function() {
it("Should handle shebang and preamble correctly", function() {
var code = UglifyJS.minify("#!/usr/bin/node\nvar x = 10;", {
- fromString: true,
output: { preamble: "/* Build */" }
}).code;
assert.strictEqual(code, "#!/usr/bin/node\n/* Build */\nvar x=10;");
@@ -83,7 +82,6 @@ describe("comment filters", function() {
it("Should handle preamble without shebang correctly", function() {
var code = UglifyJS.minify("var x = 10;", {
- fromString: true,
output: { preamble: "/* Build */" }
}).code;
assert.strictEqual(code, "/* Build */\nvar x=10;");
diff --git a/test/mocha/comment.js b/test/mocha/comment.js
index 56470e0f..acad3693 100644
--- a/test/mocha/comment.js
+++ b/test/mocha/comment.js
@@ -20,7 +20,7 @@ describe("Comment", function() {
for (var i = 0; i < tests.length; i++) {
assert.throws(function() {
- uglify.parse(tests[i], {fromString: true})
+ uglify.parse(tests[i]);
}, fail, tests[i]);
}
});
@@ -43,7 +43,7 @@ describe("Comment", function() {
for (var i = 0; i < tests.length; i++) {
assert.throws(function() {
- uglify.parse(tests[i], {fromString: true})
+ uglify.parse(tests[i]);
}, fail, tests[i]);
}
});
diff --git a/test/mocha/comment_before_constant.js b/test/mocha/comment_before_constant.js
index eaa8691c..9b69e078 100644
--- a/test/mocha/comment_before_constant.js
+++ b/test/mocha/comment_before_constant.js
@@ -6,9 +6,7 @@ describe("comment before constant", function() {
it("Should test comment before constant is retained and output after mangle.", function() {
var result = Uglify.minify(js, {
- fromString: true,
compress: { collapse_vars: false, reduce_vars: false },
- mangle: {},
output: { comments: true },
});
assert.strictEqual(result.code, 'function f(){/*c1*/var/*c2*/n=/*c3*/!1;return n}');
@@ -16,12 +14,9 @@ describe("comment before constant", function() {
it("Should test code works when comments disabled.", function() {
var result = Uglify.minify(js, {
- fromString: true,
compress: { collapse_vars: false, reduce_vars: false },
- mangle: {},
output: { comments: false },
});
assert.strictEqual(result.code, 'function f(){var n=!1;return n}');
});
});
-
diff --git a/test/mocha/directives.js b/test/mocha/directives.js
index 5189f1ad..16279a5d 100644
--- a/test/mocha/directives.js
+++ b/test/mocha/directives.js
@@ -197,7 +197,7 @@ describe("Directives", function() {
assert.strictEqual(
uglify.minify(
'"use strict";\'use strict\';"use strict";"use strict";;\'use strict\';console.log(\'use strict\');',
- {fromString: true, output: {beautify: true, quote_style: 3}, compress: false}
+ {output: {beautify: true, quote_style: 3}, compress: false}
).code,
'"use strict";\n\n\'use strict\';\n\n"use strict";\n\n"use strict";\n\n;\'use strict\';\n\nconsole.log(\'use strict\');'
);
@@ -225,7 +225,7 @@ describe("Directives", function() {
for (var i = 0; i < tests.length; i++) {
assert.strictEqual(
- uglify.minify(tests[i][0], {fromString: true, quote_style: 3, compress: false, mangle: false}).code,
+ uglify.minify(tests[i][0], {compress: false, mangle: false}).code,
tests[i][1],
tests[i][0]
);
@@ -234,7 +234,7 @@ describe("Directives", function() {
it("Should add double semicolon when relying on automatic semicolon insertion", function() {
var code = uglify.minify('"use strict";"use\\x20strict";',
- {fromString: true, output: {semicolons: false}, compress: false}
+ {output: {semicolons: false}, compress: false}
).code;
assert.strictEqual(code, '"use strict";;"use strict"\n');
});
@@ -340,7 +340,7 @@ describe("Directives", function() {
];
for (var i = 0; i < tests.length; i++) {
assert.strictEqual(
- uglify.minify(tests[i][0], {fromString: true, output:{quote_style: tests[i][1]}, compress: false}).code,
+ uglify.minify(tests[i][0], {output:{quote_style: tests[i][1]}, compress: false}).code,
tests[i][2],
tests[i][0] + " using mode " + tests[i][1]
);
@@ -362,7 +362,7 @@ describe("Directives", function() {
for (var i = 0; i < tests.length; i++) {
assert.strictEqual(
- uglify.minify(tests[i][0], {fromString: true, compress: {collapse_vars: true, side_effects: true}}).code,
+ uglify.minify(tests[i][0], {compress: {collapse_vars: true, side_effects: true}}).code,
tests[i][1],
tests[i][0]
);
diff --git a/test/mocha/glob.js b/test/mocha/glob.js
index e9555a52..56d3f82a 100644
--- a/test/mocha/glob.js
+++ b/test/mocha/glob.js
@@ -1,58 +1,80 @@
-var Uglify = require('../../');
var assert = require("assert");
+var exec = require("child_process").exec;
var path = require("path");
+var readFileSync = require("fs").readFileSync;
-describe("minify() with input file globs", function() {
- it("minify() with one input file glob string.", function() {
- var result = Uglify.minify("test/input/issue-1242/foo.*");
- assert.strictEqual(result.code, 'function foo(o){print("Foo:",2*o)}var print=console.log.bind(console);');
+describe("bin/uglifyjs with input file globs", function() {
+ var uglifyjscmd = '"' + process.argv[0] + '" bin/uglifyjs';
+ it("bin/uglifyjs with one input file extension glob.", function(done) {
+ var command = uglifyjscmd + ' "test/input/issue-1242/foo.*" -cm';
+
+ exec(command, function(err, stdout) {
+ if (err) throw err;
+
+ assert.strictEqual(stdout, 'function foo(o){print("Foo:",2*o)}var print=console.log.bind(console);\n');
+ done();
+ });
});
- it("minify() with an array of one input file glob.", function() {
- var result = Uglify.minify([
- "test/input/issue-1242/b*.es5",
- ]);
- assert.strictEqual(result.code, 'function bar(n){return 3*n}function baz(n){return n/2}');
+ it("bin/uglifyjs with one input file name glob.", function(done) {
+ var command = uglifyjscmd + ' "test/input/issue-1242/b*.es5" -cm';
+
+ exec(command, function(err, stdout) {
+ if (err) throw err;
+
+ assert.strictEqual(stdout, 'function bar(n){return 3*n}function baz(n){return n/2}\n');
+ done();
+ });
});
- it("minify() with an array of multiple input file globs.", function() {
- var result = Uglify.minify([
- "test/input/issue-1242/???.es5",
- "test/input/issue-1242/*.js",
- ], {
- compress: { toplevel: true }
+ it("bin/uglifyjs with multiple input file globs.", function(done) {
+ var command = uglifyjscmd + ' "test/input/issue-1242/???.es5" "test/input/issue-1242/*.js" -mc toplevel';
+
+ exec(command, function(err, stdout) {
+ if (err) throw err;
+
+ assert.strictEqual(stdout, 'var print=console.log.bind(console),a=function(n){return 3*n}(3),b=function(n){return n/2}(12);print("qux",a,b),function(n){print("Foo:",2*n)}(11);\n');
+ done();
});
- assert.strictEqual(result.code, 'var print=console.log.bind(console),a=function(n){return 3*n}(3),b=function(n){return n/2}(12);print("qux",a,b),function(n){print("Foo:",2*n)}(11);');
});
- it("should throw with non-matching glob string", function() {
- var glob = "test/input/issue-1242/blah.*";
- assert.strictEqual(Uglify.simple_glob(glob).length, 1);
- assert.strictEqual(Uglify.simple_glob(glob)[0], glob);
- assert.throws(function() {
- Uglify.minify(glob);
- }, "should throw file not found");
+ it("should throw with non-matching glob string", function(done) {
+ var command = uglifyjscmd + ' "test/input/issue-1242/blah.*"';
+
+ exec(command, function(err, stdout, stderr) {
+ assert.ok(err);
+ assert.ok(/^ERROR: ENOENT/.test(stderr));
+ done();
+ });
});
- it('"?" in glob string should not match "/"', function() {
- var glob = "test/input?issue-1242/foo.*";
- assert.strictEqual(Uglify.simple_glob(glob).length, 1);
- assert.strictEqual(Uglify.simple_glob(glob)[0], glob);
- assert.throws(function() {
- Uglify.minify(glob);
- }, "should throw file not found");
+ it('"?" in glob string should not match "/"', function(done) {
+ var command = uglifyjscmd + ' "test/input?issue-1242/foo.*"';
+
+ exec(command, function(err, stdout, stderr) {
+ assert.ok(err);
+ assert.ok(/^ERROR: ENOENT/.test(stderr));
+ done();
+ });
});
- it("should handle special characters in glob string", function() {
- var result = Uglify.minify("test/input/issue-1632/^{*}[???](*)+$.??");
- assert.strictEqual(result.code, "console.log(x);");
+ it("should handle special characters in glob string", function(done) {
+ var command = uglifyjscmd + ' "test/input/issue-1632/^{*}[???](*)+$.??" -cm';
+
+ exec(command, function(err, stdout) {
+ if (err) throw err;
+
+ assert.strictEqual(stdout, "console.log(x);\n");
+ done();
+ });
});
- it("should handle array of glob strings - matching and otherwise", function() {
+ it("should handle array of glob strings - matching and otherwise", function(done) {
var dir = "test/input/issue-1242";
- var matches = Uglify.simple_glob([
+ var command = uglifyjscmd + ' "' + [
path.join(dir, "b*.es5"),
path.join(dir, "z*.es5"),
- path.join(dir, "*.js"),
- ]);
- assert.strictEqual(matches.length, 4);
- assert.strictEqual(matches[0], path.join(dir, "bar.es5"));
- assert.strictEqual(matches[1], path.join(dir, "baz.es5"));
- assert.strictEqual(matches[2], path.join(dir, "z*.es5"));
- assert.strictEqual(matches[3], path.join(dir, "qux.js"));
+ path.join(dir, "*.js")
+ ].join('" "') + '"';
+
+ exec(command, function(err, stdout, stderr) {
+ assert.ok(err);
+ assert.ok(/^ERROR: ENOENT.*?z\*\.es5/.test(stderr));
+ done();
+ });
});
});
diff --git a/test/mocha/huge-number-of-comments.js b/test/mocha/huge-number-of-comments.js
index 3b90bc0e..a58f8d0a 100644
--- a/test/mocha/huge-number-of-comments.js
+++ b/test/mocha/huge-number-of-comments.js
@@ -8,12 +8,7 @@ describe("Huge number of comments.", function() {
for (i = 1; i <= 5000; ++i) { js += "// " + i + "\n"; }
for (; i <= 10000; ++i) { js += "/* " + i + " */ /**/"; }
js += "x; }";
- var result = Uglify.minify(js, {
- fromString: true,
- mangle: false,
- compress: {}
- });
+ var result = Uglify.minify(js, { mangle: false });
assert.strictEqual(result.code, "function lots_of_comments(x){return 7-x}");
});
});
-
diff --git a/test/mocha/input-sourcemaps.js b/test/mocha/input-sourcemaps.js
index d5284e3c..bda6e1a2 100644
--- a/test/mocha/input-sourcemaps.js
+++ b/test/mocha/input-sourcemaps.js
@@ -25,9 +25,9 @@ describe("input sourcemaps", function() {
transpilemap = sourceMap || getMap();
var result = Uglify.minify(transpiled, {
- fromString: true,
- inSourceMap: transpilemap,
- outSourceMap: true
+ sourceMap: {
+ content: transpilemap
+ }
});
map = new SourceMapConsumer(result.map);
diff --git a/test/mocha/let.js b/test/mocha/let.js
index 89fd9f1a..f41fd59b 100644
--- a/test/mocha/let.js
+++ b/test/mocha/let.js
@@ -11,7 +11,7 @@ describe("let", function() {
s += "var v" + i + "=0;";
}
s += '}';
- var result = Uglify.minify(s, {fromString: true, compress: false});
+ var result = Uglify.minify(s, {compress: false});
// Verify that select keywords and reserved keywords not produced
assert.strictEqual(result.code.indexOf("var let="), -1);
diff --git a/test/mocha/line-endings.js b/test/mocha/line-endings.js
index 10e2a1c5..379ee2b9 100644
--- a/test/mocha/line-endings.js
+++ b/test/mocha/line-endings.js
@@ -3,9 +3,8 @@ var assert = require("assert");
describe("line-endings", function() {
var options = {
- fromString: true,
- mangle: false,
compress: false,
+ mangle: false,
output: {
beautify: false,
comments: /^!/,
diff --git a/test/mocha/minify-file-map.js b/test/mocha/minify-file-map.js
index 169e730e..cae5ccb7 100644
--- a/test/mocha/minify-file-map.js
+++ b/test/mocha/minify-file-map.js
@@ -6,43 +6,41 @@ describe("Input file as map", function() {
var jsMap = {
'/scripts/foo.js': 'var foo = {"x": 1, y: 2, \'z\': 3};'
};
- var result = Uglify.minify(jsMap, {fromString: true, outSourceMap: true});
+ var result = Uglify.minify(jsMap, {sourceMap: true});
var map = JSON.parse(result.map);
assert.strictEqual(result.code, 'var foo={x:1,y:2,z:3};');
assert.deepEqual(map.sources, ['/scripts/foo.js']);
assert.strictEqual(map.file, undefined);
- result = Uglify.minify(jsMap, {fromString: true, outFileName: 'out.js'});
- assert.strictEqual(result.map, null);
+ result = Uglify.minify(jsMap);
+ assert.strictEqual(result.map, undefined);
- result = Uglify.minify(jsMap, {fromString: true, outFileName: 'out.js', outSourceMap: true});
+ result = Uglify.minify(jsMap, {sourceMap: {filename: 'out.js'}});
map = JSON.parse(result.map);
assert.strictEqual(map.file, 'out.js');
});
- it("Should accept array of objects and strings", function() {
+ it("Should accept array of strings", function() {
var jsSeq = [
- {'/scripts/foo.js': 'var foo = {"x": 1, y: 2, \'z\': 3};'},
+ 'var foo = {"x": 1, y: 2, \'z\': 3};',
'var bar = 15;'
];
- var result = Uglify.minify(jsSeq, {fromString: true, outSourceMap: true});
+ var result = Uglify.minify(jsSeq, {sourceMap: true});
var map = JSON.parse(result.map);
assert.strictEqual(result.code, 'var foo={x:1,y:2,z:3},bar=15;');
- assert.strictEqual(map.sources[0], '/scripts/foo.js');
+ assert.deepEqual(map.sources, ['0', '1']);
});
it("Should correctly include source", function() {
- var jsSeq = [
- {'/scripts/foo.js': 'var foo = {"x": 1, y: 2, \'z\': 3};'},
- 'var bar = 15;'
- ];
- var result = Uglify.minify(jsSeq, {fromString: true, outSourceMap: true, sourceMapIncludeSources: true});
+ var jsMap = {
+ '/scripts/foo.js': 'var foo = {"x": 1, y: 2, \'z\': 3};'
+ };
+ var result = Uglify.minify(jsMap, {sourceMap: {includeSources: true}});
var map = JSON.parse(result.map);
- assert.strictEqual(result.code, 'var foo={x:1,y:2,z:3},bar=15;');
- assert.deepEqual(map.sourcesContent, ['var foo = {"x": 1, y: 2, \'z\': 3};', 'var bar = 15;']);
+ assert.strictEqual(result.code, 'var foo={x:1,y:2,z:3};');
+ assert.deepEqual(map.sourcesContent, ['var foo = {"x": 1, y: 2, \'z\': 3};']);
});
-
});
diff --git a/test/mocha/minify.js b/test/mocha/minify.js
index a4587cb7..18840a58 100644
--- a/test/mocha/minify.js
+++ b/test/mocha/minify.js
@@ -2,10 +2,14 @@ var Uglify = require('../../');
var assert = require("assert");
var readFileSync = require("fs").readFileSync;
+function read(path) {
+ return readFileSync(path, "utf8");
+}
+
describe("minify", function() {
it("Should test basic sanity of minify with default options", function() {
var js = 'function foo(bar) { if (bar) return 3; else return 7; var u = not_called(); }';
- var result = Uglify.minify(js, {fromString: true});
+ var result = Uglify.minify(js);
assert.strictEqual(result.code, 'function foo(n){return n?3:7}');
});
@@ -13,7 +17,7 @@ describe("minify", function() {
it("Should preserve quotes in object literals", function() {
var js = 'var foo = {"x": 1, y: 2, \'z\': 3};';
var result = Uglify.minify(js, {
- fromString: true, output: {
+ output: {
keep_quoted_props: true
}});
assert.strictEqual(result.code, 'var foo={"x":1,y:2,"z":3};');
@@ -22,7 +26,7 @@ describe("minify", function() {
it("Should preserve quote styles when quote_style is 3", function() {
var js = 'var foo = {"x": 1, y: 2, \'z\': 3};';
var result = Uglify.minify(js, {
- fromString: true, output: {
+ output: {
keep_quoted_props: true,
quote_style: 3
}});
@@ -32,7 +36,7 @@ describe("minify", function() {
it("Should not preserve quotes in object literals when disabled", function() {
var js = 'var foo = {"x": 1, y: 2, \'z\': 3};';
var result = Uglify.minify(js, {
- fromString: true, output: {
+ output: {
keep_quoted_props: false,
quote_style: 3
}});
@@ -44,12 +48,13 @@ describe("minify", function() {
it("Shouldn't mangle quoted properties", function() {
var js = 'a["foo"] = "bar"; a.color = "red"; x = {"bar": 10};';
var result = Uglify.minify(js, {
- fromString: true,
compress: {
properties: false
},
- mangleProperties: {
- ignore_quoted: true
+ mangle: {
+ properties: {
+ keep_quoted: true
+ }
},
output: {
keep_quoted_props: true,
@@ -63,10 +68,12 @@ describe("minify", function() {
describe("inSourceMap", function() {
it("Should read the given string filename correctly when sourceMapIncludeSources is enabled (#1236)", function() {
- var result = Uglify.minify('./test/input/issue-1236/simple.js', {
- outSourceMap: "simple.min.js.map",
- inSourceMap: "./test/input/issue-1236/simple.js.map",
- sourceMapIncludeSources: true
+ var result = Uglify.minify(read("./test/input/issue-1236/simple.js"), {
+ sourceMap: {
+ content: read("./test/input/issue-1236/simple.js.map"),
+ filename: "simple.min.js",
+ includeSources: true
+ }
});
var map = JSON.parse(result.map);
@@ -77,10 +84,12 @@ describe("minify", function() {
'let foo = x => "foo " + x;\nconsole.log(foo("bar"));');
});
it("Should process inline source map", function() {
- var code = Uglify.minify("./test/input/issue-520/input.js", {
+ var code = Uglify.minify(read("./test/input/issue-520/input.js"), {
compress: { toplevel: true },
- inSourceMap: "inline",
- sourceMapInline: true
+ sourceMap: {
+ content: "inline",
+ url: "inline"
+ }
}).code + "\n";
assert.strictEqual(code, readFileSync("test/input/issue-520/output.js", "utf8"));
});
@@ -91,9 +100,11 @@ describe("minify", function() {
warnings.push(txt);
};
try {
- var result = Uglify.minify("./test/input/issue-1323/sample.js", {
- inSourceMap: "inline",
+ var result = Uglify.minify(read("./test/input/issue-1323/sample.js"), {
mangle: false,
+ sourceMap: {
+ content: "inline"
+ }
});
assert.strictEqual(result.code, "var bar=function(){function foo(bar){return bar}return foo}();");
assert.strictEqual(warnings.length, 1);
@@ -105,20 +116,13 @@ describe("minify", function() {
it("Should fail with multiple input and inline source map", function() {
assert.throws(function() {
Uglify.minify([
- "./test/input/issue-520/input.js",
- "./test/input/issue-520/output.js"
+ read("./test/input/issue-520/input.js"),
+ read("./test/input/issue-520/output.js")
], {
- inSourceMap: "inline",
- sourceMapInline: true
- });
- });
- });
- it("Should fail with SpiderMonkey and inline source map", function() {
- assert.throws(function() {
- Uglify.minify("./test/input/issue-520/input.js", {
- inSourceMap: "inline",
- sourceMapInline: true,
- spidermonkey: true
+ sourceMap: {
+ content: "inline",
+ url: "inline"
+ }
});
});
});
@@ -127,17 +131,16 @@ describe("minify", function() {
describe("sourceMapInline", function() {
it("should append source map to output js when sourceMapInline is enabled", function() {
var result = Uglify.minify('var a = function(foo) { return foo; };', {
- fromString: true,
- sourceMapInline: true
+ sourceMap: {
+ url: "inline"
+ }
});
var code = result.code;
assert.strictEqual(code, "var a=function(n){return n};\n" +
- "//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIj8iXSwibmFtZXMiOlsiYSIsImZvbyJdLCJtYXBwaW5ncyI6IkFBQUEsR0FBSUEsR0FBSSxTQUFTQyxHQUFPLE1BQU9BIn0=");
+ "//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIjAiXSwibmFtZXMiOlsiYSIsImZvbyJdLCJtYXBwaW5ncyI6IkFBQUEsR0FBSUEsR0FBSSxTQUFTQyxHQUFPLE1BQU9BIn0=");
});
it("should not append source map to output js when sourceMapInline is not enabled", function() {
- var result = Uglify.minify('var a = function(foo) { return foo; };', {
- fromString: true
- });
+ var result = Uglify.minify('var a = function(foo) { return foo; };');
var code = result.code;
assert.strictEqual(code, "var a=function(n){return n};");
});
@@ -146,7 +149,6 @@ describe("minify", function() {
describe("#__PURE__", function() {
it("should drop #__PURE__ hint after use", function() {
var result = Uglify.minify('//@__PURE__ comment1 #__PURE__ comment2\n foo(), bar();', {
- fromString: true,
output: {
comments: "all",
beautify: false,
@@ -157,7 +159,6 @@ describe("minify", function() {
});
it("should not drop #__PURE__ hint if function is retained", function() {
var result = Uglify.minify("var a = /*#__PURE__*/(function(){ foo(); })();", {
- fromString: true,
output: {
comments: "all",
beautify: false,
@@ -171,11 +172,11 @@ describe("minify", function() {
describe("JS_Parse_Error", function() {
it("should throw syntax error", function() {
assert.throws(function() {
- Uglify.minify("function f(a{}", { fromString: true });
+ 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.filename, "0");
assert.strictEqual(err.line, 1);
assert.strictEqual(err.col, 12);
return true;
@@ -191,5 +192,4 @@ describe("minify", function() {
assert.strictEqual(ast.print_to_string(), "function f(a){for(var i=0;i<a;i++)console.log(i)}");
});
})
-
});
diff --git a/test/mocha/new.js b/test/mocha/new.js
index 083b9964..8f653f7a 100644
--- a/test/mocha/new.js
+++ b/test/mocha/new.js
@@ -34,7 +34,6 @@ describe("New", function() {
for (var i = 0; i < tests.length; i++) {
assert.strictEqual(
uglify.minify(tests[i], {
- fromString: true,
output: {beautify: true},
compress: false,
mangle: false
@@ -76,7 +75,6 @@ describe("New", function() {
for (var i = 0; i < tests.length; i++) {
assert.strictEqual(
uglify.minify(tests[i], {
- fromString: true,
output: {beautify: false},
compress: false,
mangle: false
diff --git a/test/mocha/release.js b/test/mocha/release.js
index 3b2d9a72..b73a3df7 100644
--- a/test/mocha/release.js
+++ b/test/mocha/release.js
@@ -42,8 +42,8 @@ describe("test/jetstream.js", function() {
run("npm", ["install", "phantomjs-prebuilt@2.1.14"], done);
});
[
- "-mc warnings=false",
- "-mc keep_fargs=false,passes=3,pure_getters,unsafe,unsafe_comps,unsafe_math,unsafe_proto,warnings=false",
+ "-mc",
+ "-mc keep_fargs=false,passes=3,pure_getters,unsafe,unsafe_comps,unsafe_math,unsafe_proto",
].forEach(function(options) {
it("Should pass with options " + options, function(done) {
var args = options.split(/ /);
diff --git a/test/mocha/screw-ie8.js b/test/mocha/screw-ie8.js
index 28b092e9..e120a475 100644
--- a/test/mocha/screw-ie8.js
+++ b/test/mocha/screw-ie8.js
@@ -13,9 +13,7 @@ describe("screw-ie8", function () {
}\
console.log('undefined is ' + undefined);\
return b === undefined;\
- };", {
- fromString: true
- }
+ };"
).code,
'function a(o){try{throw"Stuff"}catch(o){console.log("caught: "+o)}return console.log("undefined is "+void 0),void 0===o}'
);
diff --git a/test/mocha/spidermonkey.js b/test/mocha/spidermonkey.js
index c1294525..e5bf45a2 100644
--- a/test/mocha/spidermonkey.js
+++ b/test/mocha/spidermonkey.js
@@ -3,14 +3,14 @@ var exec = require("child_process").exec;
var uglify = require("../../");
describe("spidermonkey export/import sanity test", function() {
- it("should produce a functional build when using --self with spidermonkey", function (done) {
+ it("should produce a functional build when using --self with spidermonkey", function(done) {
this.timeout(20000);
var uglifyjs = '"' + process.argv[0] + '" bin/uglifyjs';
- var command = uglifyjs + " --self -cm --wrap SpiderUglify --dump-spidermonkey-ast | " +
- uglifyjs + " --spidermonkey -cm";
+ var command = uglifyjs + " --self -cm --wrap SpiderUglify -o spidermonkey | " +
+ uglifyjs + " -p spidermonkey -cm";
- exec(command, function (err, stdout) {
+ exec(command, function(err, stdout) {
if (err) throw err;
eval(stdout);
diff --git a/test/ufuzz.js b/test/ufuzz.js
index 2a09e2f7..67d65045 100644
--- a/test/ufuzz.js
+++ b/test/ufuzz.js
@@ -2,7 +2,7 @@
// derived from https://github.com/qfox/uglyfuzzer by Peter van der Zee
"use strict";
-// check both cli and file modes of nodejs (!). See #1695 for details. and the various settings of uglify.
+// check both CLI and file modes of nodejs (!). See #1695 for details. and the various settings of uglify.
// bin/uglifyjs s.js -c && bin/uglifyjs s.js -c passes=3 && bin/uglifyjs s.js -c passes=3 -m
// cat s.js | node && node s.js && bin/uglifyjs s.js -c | node && bin/uglifyjs s.js -c passes=3 | node && bin/uglifyjs s.js -c passes=3 -m | node
@@ -768,7 +768,6 @@ function createVarName(maybe, dontStore) {
function try_beautify(code, result) {
try {
var beautified = UglifyJS.minify(code, {
- fromString: true,
compress: false,
mangle: false,
output: {
@@ -802,8 +801,8 @@ var default_options = {
mangle: {
"cache": null,
"eval": false,
+ "ie8": false,
"keep_fnames": false,
- "screw_ie8": true,
"toplevel": false,
},
output: infer_options(UglifyJS.OutputStream),
@@ -869,10 +868,7 @@ function log(options) {
}
}
-var minify_options = require("./ufuzz.json").map(function(options) {
- options.fromString = true;
- return JSON.stringify(options);
-});
+var minify_options = require("./ufuzz.json").map(JSON.stringify);
var original_code, original_result;
var uglify_code, uglify_result, ok;
for (var round = 1; round <= num_iterations; round++) {
diff --git a/test/ufuzz.json b/test/ufuzz.json
index c4813470..cb014b12 100644
--- a/test/ufuzz.json
+++ b/test/ufuzz.json
@@ -11,20 +11,12 @@
"compress": false
},
{
- "compress": {
- "warnings": false
- },
"mangle": false
},
+ {},
{
"compress": {
- "warnings": false
- }
- },
- {
- "compress": {
- "toplevel": true,
- "warnings": false
+ "toplevel": true
},
"mangle": {
"toplevel": true
@@ -33,8 +25,7 @@
{
"compress": {
"keep_fargs": false,
- "passes": 3,
- "warnings": false
+ "passes": 3
}
}
]