diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-11-13 04:17:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-13 04:17:09 +0800 |
commit | d6fd18d0b000e1e4fbe01259139043f42d8fdebf (patch) | |
tree | 7dca39ef5d97e53a4e5c1d062565df3d9313373f /test/compress | |
parent | 0d17c5b0fa3a4305177f9561ba1f05835a9ffea3 (diff) | |
download | tracifyjs-d6fd18d0b000e1e4fbe01259139043f42d8fdebf.tar.gz tracifyjs-d6fd18d0b000e1e4fbe01259139043f42d8fdebf.zip |
enhance `evaluate` & `inline` (#3580)
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/collapse_vars.js | 4 | ||||
-rw-r--r-- | test/compress/dead-code.js | 4 | ||||
-rw-r--r-- | test/compress/evaluate.js | 21 | ||||
-rw-r--r-- | test/compress/functions.js | 3 | ||||
-rw-r--r-- | test/compress/reduce_vars.js | 26 | ||||
-rw-r--r-- | test/compress/typeof.js | 4 |
6 files changed, 37 insertions, 25 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index 86e8d632..e67425af 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -1458,7 +1458,7 @@ collapse_vars_constants: { function f3(x) { var b = x.prop; sideeffect1(); - return b + (function() { return -9; })(); + return b + -9; } } } @@ -5748,7 +5748,7 @@ issue_3215_1: { }()); } expect: { - console.log("number"); + console.log(typeof 42); } expect_stdout: "number" } diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js index d4832c73..627630ab 100644 --- a/test/compress/dead-code.js +++ b/test/compress/dead-code.js @@ -892,9 +892,7 @@ issue_2860_1: { }()); } expect: { - console.log(function(a) { - return 1 ^ a; - }()); + console.log(1); } expect_stdout: "1" } diff --git a/test/compress/evaluate.js b/test/compress/evaluate.js index 74cb65ff..ea707e63 100644 --- a/test/compress/evaluate.js +++ b/test/compress/evaluate.js @@ -1900,3 +1900,24 @@ issue_3568: { } expect_stdout: "NaN" } + +conditional_function: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + } + input: { + function f(a) { + return a && "undefined" != typeof A ? A : 42; + } + console.log(f(0), f(1)); + } + expect: { + function f(a) { + return a && "undefined" != typeof A ? A : 42; + } + console.log(42, f(1)); + } + expect_stdout: "42 42" +} diff --git a/test/compress/functions.js b/test/compress/functions.js index 1208b62d..e36176bd 100644 --- a/test/compress/functions.js +++ b/test/compress/functions.js @@ -2265,7 +2265,8 @@ issue_3054: { return { a: !0 }; } console.log(function(b) { - return { a: !(b = !1) }; + b = !1; + return f(); }().a, f.call().a); } expect_stdout: "true true" diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index ce7c16da..a3421c00 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -1427,13 +1427,13 @@ defun_inline_3: { defun_call: { options = { - inline: true, + evaluate: true, reduce_funcs: true, reduce_vars: true, unused: true, } input: { - function f() { + console.log(function f() { return g() + h(1) - h(g(), 2, 3); function g() { return 4; @@ -1441,21 +1441,17 @@ defun_call: { function h(a) { return a; } - } + }()); } expect: { - function f() { - return 4 + h(1) - h(4); - function h(a) { - return a; - } - } + console.log(1); } + expect_stdout: "1" } defun_redefine: { options = { - inline: true, + evaluate: true, reduce_funcs: true, reduce_vars: true, unused: true, @@ -1480,7 +1476,7 @@ defun_redefine: { (function() { return 3; }); - return 3 + 2; + return 5; } console.log(f()); } @@ -1517,7 +1513,7 @@ func_inline: { func_modified: { options = { - inline: true, + evaluate: true, reduce_funcs: true, reduce_vars: true, unused: true, @@ -1550,7 +1546,7 @@ func_modified: { (function() { return 4; }); - return 1 + 2 + 4; + return 7; } console.log(f()); } @@ -5516,9 +5512,7 @@ issue_2860_1: { }()); } expect: { - console.log(function(a) { - return 1 ^ a; - }()); + console.log(1); } expect_stdout: "1" } diff --git a/test/compress/typeof.js b/test/compress/typeof.js index 3b99521e..aae7405f 100644 --- a/test/compress/typeof.js +++ b/test/compress/typeof.js @@ -166,9 +166,7 @@ duplicate_lambda_arg_name: { }()); } expect: { - console.log(function long_name(long_name) { - return typeof long_name; - }()); + console.log("undefined"); } expect_stdout: "undefined" } |