aboutsummaryrefslogtreecommitdiff
path: root/test/compress/reduce_vars.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-12-14 18:47:05 +0800
committerGitHub <noreply@github.com>2017-12-14 18:47:05 +0800
commit3f18a61532a86f0f52edbb50ca7d81e0869ad7c3 (patch)
tree943cf4b5f809d106057225215e6ea30d218fae3f /test/compress/reduce_vars.js
parent02a6ce07eba11223518a22bce18e209371f78f39 (diff)
downloadtracifyjs-3f18a61532a86f0f52edbb50ca7d81e0869ad7c3.tar.gz
tracifyjs-3f18a61532a86f0f52edbb50ca7d81e0869ad7c3.zip
fix `reduce_vars` on single `AST_Defun` reference across loop (#2593)
Diffstat (limited to 'test/compress/reduce_vars.js')
-rw-r--r--test/compress/reduce_vars.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index 108dc0e9..ff93079d 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -4838,3 +4838,31 @@ inverted_var: {
}
expect_stdout: true
}
+
+defun_single_use_loop: {
+ options = {
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ for (var x, i = 2; --i >= 0; ) {
+ var y = x;
+ x = f;
+ console.log(x === y);
+ }
+ function f() {};
+ }
+ expect: {
+ for (var x, i = 2; --i >= 0; ) {
+ var y = x;
+ x = f;
+ console.log(x === y);
+ }
+ function f() {};
+ }
+ expect_stdout: [
+ "false",
+ "true",
+ ]
+}