aboutsummaryrefslogtreecommitdiff
path: root/test/compress/drop-unused.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-12-27 05:31:37 +0800
committerGitHub <noreply@github.com>2017-12-27 05:31:37 +0800
commit3ff625de7e3d381de43b4703faae402381844c9f (patch)
tree77aa12e8ba92097aab62741549d64c5ac928c414 /test/compress/drop-unused.js
parent4832bc5d88e37ca35f1dd5f5d8ddd95cd8bbdd7d (diff)
downloadtracifyjs-3ff625de7e3d381de43b4703faae402381844c9f.tar.gz
tracifyjs-3ff625de7e3d381de43b4703faae402381844c9f.zip
fix bugs on substituted `AST_Defun` (#2661)
fixes #2660
Diffstat (limited to 'test/compress/drop-unused.js')
-rw-r--r--test/compress/drop-unused.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index 90206ec6..714e1d16 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -1434,3 +1434,57 @@ defun_lambda_same_name: {
}
expect_stdout: "120"
}
+
+issue_2660_1: {
+ options = {
+ reduce_vars: true,
+ side_effects: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var a = 2;
+ function f(b) {
+ return b && f() || a--;
+ }
+ f(1);
+ console.log(a);
+ }
+ expect: {
+ var a = 2;
+ (function f(b) {
+ return b && f() || a--;
+ })(1);
+ console.log(a);
+ }
+ expect_stdout: "1"
+}
+
+issue_2660_2: {
+ options = {
+ collapse_vars: true,
+ reduce_vars: true,
+ sequences: true,
+ side_effects: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ var a = 1;
+ function f(b) {
+ b && f();
+ --a, a.toString();
+ }
+ f();
+ console.log(a);
+ }
+ expect: {
+ var a = 1;
+ (function f(b) {
+ b && f(),
+ (--a).toString();
+ })(),
+ console.log(a);
+ }
+ expect_stdout: "0"
+}