aboutsummaryrefslogtreecommitdiff
path: root/test/compress/collapse_vars.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-11-13 07:37:42 +0800
committerGitHub <noreply@github.com>2017-11-13 07:37:42 +0800
commit49fbe9c5ac090b2082ebd4702772af6ccafa13cd (patch)
treeaaaff78264109b1f0f17bcacab92a9fabe703c36 /test/compress/collapse_vars.js
parent2ac5086831f17ae93f1cfec9b7375b8ae19915ca (diff)
downloadtracifyjs-49fbe9c5ac090b2082ebd4702772af6ccafa13cd.tar.gz
tracifyjs-49fbe9c5ac090b2082ebd4702772af6ccafa13cd.zip
fix replacement logic in `collapse_vars` (#2475)
Diffstat (limited to 'test/compress/collapse_vars.js')
-rw-r--r--test/compress/collapse_vars.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index 402bd22b..10735b28 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -3518,3 +3518,63 @@ issue_2436_12: {
}
}
}
+
+issue_2436_13: {
+ options = {
+ collapse_vars: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ var a = "PASS";
+ (function() {
+ function f(b) {
+ (function g(b) {
+ var b = b && (b.null = "FAIL");
+ })(a);
+ }
+ f();
+ })();
+ console.log(a);
+ }
+ expect: {
+ var a = "PASS";
+ (function() {
+ (function(b) {
+ (function(b) {
+ a && (a.null = "FAIL");
+ })();
+ })();
+ })();
+ console.log(a);
+ }
+ expect_stdout: "PASS"
+}
+
+issue_2436_14: {
+ options = {
+ collapse_vars: true,
+ reduce_vars: true,
+ unused: true,
+ }
+ input: {
+ var a = "PASS";
+ var b = {};
+ (function() {
+ var c = a;
+ c && function(c, d) {
+ console.log(c, d);
+ }(b, c);
+ })();
+ }
+ expect: {
+ var a = "PASS";
+ var b = {};
+ (function() {
+ a && function(c, d) {
+ console.log(c, d);
+ }(b, a);
+ })();
+ }
+ expect_stdout: true
+}