diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-11-28 13:08:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-28 13:08:40 +0800 |
commit | ecc9f6b77093758d78a693a5ac4b6bcaf75e9a3f (patch) | |
tree | d1da1a5309bd75053dae1fde43c1b086ae192e7e /test/compress | |
parent | b37a68c84f7b74de8ec7fc862792964c436fa2ec (diff) | |
download | tracifyjs-ecc9f6b77093758d78a693a5ac4b6bcaf75e9a3f.tar.gz tracifyjs-ecc9f6b77093758d78a693a5ac4b6bcaf75e9a3f.zip |
drop assignment in `AST_VarDef.value` (#2522)
fixes #2516
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/collapse_vars.js | 16 | ||||
-rw-r--r-- | test/compress/drop-unused.js | 80 |
2 files changed, 90 insertions, 6 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 844d5b0f..f968ff20 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -705,7 +705,7 @@ collapse_vars_lvalues_drop_assign: { function f2(x) { var z = x, a = ++z; return z += a; } function f3(x) { var a = (x -= 3); return x + a; } function f4(x) { var a = (x -= 3); return x + a; } - function f5(x) { e1(); var v = e2(), c = v = --x; return x - c; } + function f5(x) { e1(), e2(); var c = --x; return x - c; } function f6(x) { e1(), e2(); return --x - x; } function f7(x) { e1(); return x - (e2() - x); } function f8(x) { e1(); return x - (e2() - x); } @@ -2386,6 +2386,7 @@ duplicate_argname: { issue_2298: { options = { collapse_vars: true, + passes: 2, reduce_funcs: true, reduce_vars: true, unused: true, @@ -3087,13 +3088,14 @@ issue_2437: { } expect: { !function() { - if (xhrDesc) - return result = !!(req = new XMLHttpRequest()).onreadystatechange, - Object.defineProperty(XMLHttpRequest.prototype, "onreadystatechange", xhrDesc || {}), + if (xhrDesc) { + var result = !!(req = new XMLHttpRequest()).onreadystatechange; + return Object.defineProperty(XMLHttpRequest.prototype, "onreadystatechange", xhrDesc || {}), result; + } var req = new XMLHttpRequest(), detectFunc = function() {}; - req.onreadystatechange = detectFunc; - var result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc; + req.onreadystatechange = detectFunc, + result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc, req.onreadystatechange = null; }(); } @@ -3522,6 +3524,7 @@ issue_2436_12: { issue_2436_13: { options = { collapse_vars: true, + passes: 2, reduce_vars: true, unused: true, } @@ -3622,6 +3625,7 @@ issue_2497: { issue_2506: { options = { collapse_vars: true, + passes: 2, reduce_vars: true, unused: true, } diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js index 33241d67..eb6f9df4 100644 --- a/test/compress/drop-unused.js +++ b/test/compress/drop-unused.js @@ -1299,3 +1299,83 @@ issue_2288: { } } } + +issue_2516_1: { + options = { + collapse_vars: true, + reduce_funcs: true, + reduce_vars: true, + unused: true, + } + input: { + function foo() { + function qux(x) { + bar.call(null, x); + } + function bar(x) { + var FOUR = 4; + var trouble = x || never_called(); + var value = (FOUR - 1) * trouble; + console.log(value == 6 ? "PASS" : value); + } + Baz = qux; + } + var Baz; + foo(); + Baz(2); + } + expect: { + function foo() { + Baz = function(x) { + (function(x) { + var trouble = x || never_called(); + var value = (4 - 1) * trouble; + console.log(6 == value ? "PASS" : value); + }).call(null, x); + }; + } + var Baz; + foo(); + Baz(2); + } +} + +issue_2516_2: { + options = { + collapse_vars: true, + reduce_funcs: true, + reduce_vars: true, + passes: 2, + unused: true, + } + input: { + function foo() { + function qux(x) { + bar.call(null, x); + } + function bar(x) { + var FOUR = 4; + var trouble = x || never_called(); + var value = (FOUR - 1) * trouble; + console.log(value == 6 ? "PASS" : value); + } + Baz = qux; + } + var Baz; + foo(); + Baz(2); + } + expect: { + function foo() { + Baz = function(x) { + (function(x) { + var value = (4 - 1) * (x || never_called()); + console.log(6 == value ? "PASS" : value); + }).call(null, x); + }; + } + var Baz; + foo(); + Baz(2); + } +} |