diff options
-rw-r--r-- | test/input/reduce/diff_error.js | 5 | ||||
-rw-r--r-- | test/input/reduce/diff_error.reduced.js | 19 | ||||
-rw-r--r-- | test/mocha/reduce.js | 14 | ||||
-rw-r--r-- | test/reduce.js | 3 |
4 files changed, 40 insertions, 1 deletions
diff --git a/test/input/reduce/diff_error.js b/test/input/reduce/diff_error.js new file mode 100644 index 00000000..ba267c5c --- /dev/null +++ b/test/input/reduce/diff_error.js @@ -0,0 +1,5 @@ +(function f(a) { + do { + console.log(f.length); + } while (console.log(f += 0)); +})(); diff --git a/test/input/reduce/diff_error.reduced.js b/test/input/reduce/diff_error.reduced.js new file mode 100644 index 00000000..a76e3d94 --- /dev/null +++ b/test/input/reduce/diff_error.reduced.js @@ -0,0 +1,19 @@ +// (beautified) +(function f(a) { + do { + console.log(f.length); + } while (console.log(f += 0)); +})(); +// output: 1 +// function(){}0 +// +// minify: 0 +// function(){}0 +// +// options: { +// "compress": { +// "keep_fargs": false, +// "unsafe": true +// }, +// "mangle": false +// }
\ No newline at end of file diff --git a/test/mocha/reduce.js b/test/mocha/reduce.js index 271358be..c1864735 100644 --- a/test/mocha/reduce.js +++ b/test/mocha/reduce.js @@ -296,4 +296,18 @@ describe("test/reduce.js", function() { "// }", ]).join("\n")); }); + it("Should handle corner cases when intermediate case differs only in Error.message", function() { + if (semver.satisfies(process.version, "<=0.10")) return; + var result = reduce_test(read("test/input/reduce/diff_error.js"), { + compress: { + keep_fargs: false, + unsafe: true, + }, + mangle: false, + }, { + verbose: false, + }); + if (result.error) throw result.error; + assert.strictEqual(result.code, read("test/input/reduce/diff_error.reduced.js")); + }); }); diff --git a/test/reduce.js b/test/reduce.js index ff2f787c..7f37ea25 100644 --- a/test/reduce.js +++ b/test/reduce.js @@ -438,7 +438,8 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options) } })); var code = testcase_ast.print_to_string(); - if (diff = test_for_diff(code, minify_options, result_cache, max_timeout)) { + var diff = test_for_diff(code, minify_options, result_cache, max_timeout); + if (diff && !diff.timed_out && !diff.error) { testcase = code; differs = diff; } else { |