diff --git a/test/compress/blocks.js b/test/compress/blocks.js index 971dd861..46533e9d 100644 --- a/test/compress/blocks.js +++ b/test/compress/blocks.js @@ -75,6 +75,7 @@ issue_1664: { } expect_stdout: "1" node_version: ">=6" + reminify: false // FIXME - block scoped function } issue_1672_for: { diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js index dac3818d..e3c0d549 100644 --- a/test/compress/dead-code.js +++ b/test/compress/dead-code.js @@ -60,6 +60,7 @@ dead_code_2_should_warn: { } expect_stdout: true node_version: ">=6" + reminify: false // FIXME - block scoped function } dead_code_2_should_warn_strict: { @@ -100,6 +101,7 @@ dead_code_2_should_warn_strict: { } expect_stdout: true node_version: ">=4" + reminify: false // FIXME - block scoped function } dead_code_constant_boolean_should_warn_more: { @@ -135,6 +137,7 @@ dead_code_constant_boolean_should_warn_more: { } expect_stdout: true node_version: ">=6" + reminify: false // FIXME - block scoped function } dead_code_constant_boolean_should_warn_more_strict: { @@ -171,6 +174,7 @@ dead_code_constant_boolean_should_warn_more_strict: { } expect_stdout: true node_version: ">=4" + reminify: false // FIXME - block scoped function } dead_code_block_decls_die: { diff --git a/test/compress/issue-1466.js b/test/compress/issue-1466.js index 1eee16b3..2f9ba975 100644 --- a/test/compress/issue-1466.js +++ b/test/compress/issue-1466.js @@ -79,6 +79,7 @@ same_variable_in_multiple_forOf: { } } expect_stdout: true + reminify: false // FIXME - regression https://github.com/mishoo/UglifyJS2/issues/2835 } same_variable_in_multiple_forIn: { @@ -120,6 +121,7 @@ same_variable_in_multiple_forIn: { } } expect_stdout: true + reminify: false // FIXME - regression https://github.com/mishoo/UglifyJS2/issues/2835 } different_variable_in_multiple_for_loop: { diff --git a/test/run-tests.js b/test/run-tests.js index 1a0b8d46..deb1f954 100755 --- a/test/run-tests.js +++ b/test/run-tests.js @@ -208,6 +208,9 @@ function run_compress_tests() { }); return false; } + if (test.reminify && !reminify(test.options, input_code, input_formatted, test.expect_stdout)) { + return false; + } } return true; } @@ -261,6 +264,16 @@ function parse_test(file) { })); } + function read_boolean(stat) { + if (stat.TYPE == "SimpleStatement") { + var body = stat.body; + if (body instanceof U.AST_Boolean) { + return body.value; + } + } + throw new Error("Should be boolean"); + } + function read_string(stat) { if (stat.TYPE == "SimpleStatement") { var body = stat.body; @@ -279,7 +292,11 @@ function parse_test(file) { } function get_one_test(name, block) { - var test = { name: name, options: {} }; + var test = { + name: name, + options: {}, + reminify: true, + }; var tw = new U.TreeWalker(function(node, descend){ if (node instanceof U.AST_Assign) { if (!(node.left instanceof U.AST_SymbolRef)) { @@ -299,6 +316,7 @@ function parse_test(file) { "expect_warnings", "expect_stdout", "node_version", + "reminify", ].indexOf(label.name) >= 0, tmpl("Unsupported label {name} [{line},{col}]", { name: label.name, @@ -309,6 +327,9 @@ function parse_test(file) { var stat = node.body; if (label.name == "expect_exact" || label.name == "node_version") { test[label.name] = read_string(stat); + } else if (label.name == "reminify") { + var value = read_boolean(stat); + test.reminify = value == null || value; } else if (label.name == "expect_stdout") { var body = stat.body; if (body instanceof U.AST_Boolean) { @@ -358,14 +379,17 @@ function evaluate(code) { function reminify(orig_options, input_code, input_formatted, expect_stdout) { for (var i = 0; i < minify_options.length; i++) { var options = JSON.parse(minify_options[i]); - if (options.compress) [ - "keep_fargs", - "keep_fnames", - ].forEach(function(name) { - if (name in orig_options) { - options.compress[name] = orig_options[name]; - } - }); + options.keep_fnames = orig_options.keep_fnames; + options.keep_classnames = orig_options.keep_classnames; + if (orig_options.compress) { + options.compress.keep_classnames = orig_options.compress.keep_classnames; + options.compress.keep_fargs = orig_options.compress.keep_fargs; + options.compress.keep_fnames = orig_options.compress.keep_fnames; + } + if (orig_options.mangle) { + options.mangle.keep_classnames = orig_options.mangle.keep_classnames; + options.mangle.keep_fnames = orig_options.mangle.keep_fnames; + } var options_formatted = JSON.stringify(options, null, 4); var result = U.minify(input_code, options); if (result.error) {