aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-04-10 02:46:38 +0800
committerGitHub <noreply@github.com>2018-04-10 02:46:38 +0800
commit183da16896513c22b73d219affebeb155fb8ecdf (patch)
tree89dcb07c7f71b43e5af0b3c6199ccdb80e2f6afb /test/compress
parent87857b0f1bcb428d36cf715d8ac218eebed6a3ff (diff)
downloadtracifyjs-183da16896513c22b73d219affebeb155fb8ecdf.tar.gz
tracifyjs-183da16896513c22b73d219affebeb155fb8ecdf.zip
handle `pure_funcs` under `inline` & `reduce_vars` correctly (#3066)
fixes #3065
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/pure_funcs.js107
1 files changed, 107 insertions, 0 deletions
diff --git a/test/compress/pure_funcs.js b/test/compress/pure_funcs.js
index 0df51e5f..56c36dd7 100644
--- a/test/compress/pure_funcs.js
+++ b/test/compress/pure_funcs.js
@@ -535,3 +535,110 @@ issue_2705_6: {
"/* */new(/* */a()||b())(c(),d());",
]
}
+
+issue_3065_1: {
+ options = {
+ inline: true,
+ pure_funcs: [ "pureFunc" ],
+ reduce_vars: true,
+ side_effects: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ function modifyWrapper(a, f, wrapper) {
+ wrapper.a = a;
+ wrapper.f = f;
+ return wrapper;
+ }
+ function pureFunc(fun) {
+ return modifyWrapper(1, fun, function(a) {
+ return fun(a);
+ });
+ }
+ var unused = pureFunc(function(x) {
+ return x;
+ });
+ }
+ expect: {}
+}
+
+issue_3065_2: {
+ rename = true
+ options = {
+ inline: true,
+ pure_funcs: [ "pureFunc" ],
+ reduce_vars: true,
+ side_effects: true,
+ toplevel: true,
+ unused: true,
+ }
+ mangle = {
+ reserved: [ "pureFunc" ],
+ toplevel: true,
+ }
+ input: {
+ function modifyWrapper(a, f, wrapper) {
+ wrapper.a = a;
+ wrapper.f = f;
+ return wrapper;
+ }
+ function pureFunc(fun) {
+ return modifyWrapper(1, fun, function(a) {
+ return fun(a);
+ });
+ }
+ var unused = pureFunc(function(x) {
+ return x;
+ });
+ }
+ expect: {}
+}
+
+issue_3065_3: {
+ options = {
+ pure_funcs: [ "debug" ],
+ reduce_vars: true,
+ side_effects: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ function debug(msg) {
+ console.log(msg);
+ }
+ debug(function() {
+ console.log("PASS");
+ return "FAIL";
+ }());
+ }
+ expect: {
+ (function() {
+ console.log("PASS");
+ })();
+ }
+}
+
+issue_3065_4: {
+ options = {
+ pure_funcs: [ "debug" ],
+ reduce_vars: true,
+ side_effects: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var debug = function(msg) {
+ console.log(msg);
+ };
+ debug(function() {
+ console.log("PASS");
+ return "FAIL";
+ }());
+ }
+ expect: {
+ (function() {
+ console.log("PASS");
+ })();
+ }
+}