aboutsummaryrefslogtreecommitdiff
path: root/test/compress/collapse_vars.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-12-13 04:52:54 +0800
committerGitHub <noreply@github.com>2017-12-13 04:52:54 +0800
commit04cc395c353ac622d8e737c9099387d69b851d64 (patch)
treeb4c34f6ae443746713e524540d4cb15906d1cba4 /test/compress/collapse_vars.js
parente008dc1bde1455eaafe04061412b0b9524212d99 (diff)
downloadtracifyjs-04cc395c353ac622d8e737c9099387d69b851d64.tar.gz
tracifyjs-04cc395c353ac622d8e737c9099387d69b851d64.zip
improve `collapse_vars` on side-effect-free replacements (#2583)
Diffstat (limited to 'test/compress/collapse_vars.js')
-rw-r--r--test/compress/collapse_vars.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index 330667dd..58405801 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -3805,3 +3805,51 @@ may_throw: {
}
}
}
+
+side_effect_free_replacement: {
+ options = {
+ collapse_vars: true,
+ inline: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ var b;
+ (function(a) {
+ x(a);
+ })(b);
+ }
+ expect: {
+ var b;
+ x(b);
+ }
+}
+
+recursive_function_replacement: {
+ rename = true
+ options = {
+ collapse_vars: true,
+ inline: true,
+ passes: 2,
+ reduce_funcs: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ mangle = {}
+ input: {
+ function f(a) {
+ return x(g(a));
+ }
+ function g(a) {
+ return y(f(a));
+ }
+ console.log(f(c));
+ }
+ expect: {
+ function f(n) {
+ return x(y(f(n)));
+ }
+ console.log(f(c));
+ }
+}