aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-04-24 05:45:18 +0100
committerGitHub <noreply@github.com>2021-04-24 12:45:18 +0800
commit10dd9d4eaf3d28479744676e344f0df6b6bd8029 (patch)
tree990175949b8411e2d55fba8b17f0bed1126b6a29 /test
parent9b8deff64d957b2804082572340cdd8175eff731 (diff)
downloadtracifyjs-10dd9d4eaf3d28479744676e344f0df6b6bd8029.tar.gz
tracifyjs-10dd9d4eaf3d28479744676e344f0df6b6bd8029.zip
enhance `collapse_vars` (#4864)
Diffstat (limited to 'test')
-rw-r--r--test/compress/collapse_vars.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index fcc47391..451681b6 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -8064,6 +8064,67 @@ mangleable_var: {
expect_stdout: "PASS"
}
+mangleable_assignment_1: {
+ options = {
+ collapse_vars: true,
+ unused: true,
+ }
+ input: {
+ var o = {
+ p: function() {
+ return 6;
+ },
+ };
+ (function() {
+ var a, b = a = o.p();
+ console.log(a * (b / a + b));
+ })();
+ }
+ expect: {
+ var o = {
+ p: function() {
+ return 6;
+ },
+ };
+ (function() {
+ var a;
+ a = o.p();
+ console.log(a * (a / a + a));
+ })();
+ }
+ expect_stdout: "42"
+}
+
+mangleable_assignment_2: {
+ options = {
+ collapse_vars: true,
+ unused: true,
+ }
+ input: {
+ var o = {
+ p: function() {
+ return 6;
+ },
+ };
+ (function(a, b) {
+ b = a = o.p();
+ console.log(a * (b / a + b));
+ })();
+ }
+ expect: {
+ var o = {
+ p: function() {
+ return 6;
+ },
+ };
+ (function(a, b) {
+ a = o.p();
+ console.log(a * (a / a + a));
+ })();
+ }
+ expect_stdout: "42"
+}
+
issue_3884_1: {
options = {
collapse_vars: true,