aboutsummaryrefslogtreecommitdiff
path: root/test/compress/reduce_vars.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-05-04 06:05:38 +0800
committerGitHub <noreply@github.com>2018-05-04 06:05:38 +0800
commitc4cebb4b01e3d1dc75da50a9e3fb05d4d342407f (patch)
treef81e67fbf6dfed8d029e263c26eab04e326b796d /test/compress/reduce_vars.js
parentd51a00a4508022e54e257d93442abff42c4442b7 (diff)
downloadtracifyjs-c4cebb4b01e3d1dc75da50a9e3fb05d4d342407f.tar.gz
tracifyjs-c4cebb4b01e3d1dc75da50a9e3fb05d4d342407f.zip
fix `reduce_vars` on nested invocations (#3118)
Diffstat (limited to 'test/compress/reduce_vars.js')
-rw-r--r--test/compress/reduce_vars.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index c4308d38..1d6d1896 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -5939,3 +5939,62 @@ issue_3113_3: {
}
expect_stdout: "1"
}
+
+issue_3113_4: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ toplevel: true,
+ }
+ input: {
+ var a = 0, b = 0;
+ function f() {
+ b += a;
+ }
+ f(f(), ++a);
+ console.log(a, b);
+ }
+ expect: {
+ var a = 0, b = 0;
+ function f() {
+ b += a;
+ }
+ f(f(), ++a);
+ console.log(a, b);
+ }
+ expect_stdout: "1 1"
+}
+
+issue_3113_5: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ toplevel: true,
+ }
+ input: {
+ function f() {
+ console.log(a);
+ }
+ function g() {
+ f();
+ }
+ while (g());
+ var a = 1;
+ f();
+ }
+ expect: {
+ function f() {
+ console.log(a);
+ }
+ function g() {
+ f();
+ }
+ while (g());
+ var a = 1;
+ f();
+ }
+ expect_stdout: [
+ "undefined",
+ "1",
+ ]
+}