aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-05-03 15:51:51 +0800
committerGitHub <noreply@github.com>2018-05-03 15:51:51 +0800
commitfc0f168a0c4d81d724339af881b6ad466e02b0b5 (patch)
tree4ba33140d7372c126ca2b9ffeaeb8e173c075e70 /test
parenta0ca595c2c51809181908b9122992702aec888ab (diff)
downloadtracifyjs-fc0f168a0c4d81d724339af881b6ad466e02b0b5.tar.gz
tracifyjs-fc0f168a0c4d81d724339af881b6ad466e02b0b5.zip
better fix for #3113 (#3115)
Diffstat (limited to 'test')
-rw-r--r--test/compress/reduce_vars.js72
1 files changed, 71 insertions, 1 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js
index b21b760b..c4308d38 100644
--- a/test/compress/reduce_vars.js
+++ b/test/compress/reduce_vars.js
@@ -5834,7 +5834,7 @@ issue_3110_3: {
]
}
-issue_3113: {
+issue_3113_1: {
options = {
evaluate: true,
reduce_vars: true,
@@ -5869,3 +5869,73 @@ issue_3113: {
}
expect_stdout: "1"
}
+
+issue_3113_2: {
+ options = {
+ evaluate: true,
+ reduce_vars: true,
+ }
+ input: {
+ var c = 0;
+ (function() {
+ function f() {
+ while (g());
+ }
+ var a = f();
+ function g() {
+ a && a[c++];
+ }
+ a = 1;
+ g();
+ })();
+ console.log(c);
+ }
+ expect: {
+ var c = 0;
+ (function() {
+ function f() {
+ while (g());
+ }
+ var a = f();
+ function g() {
+ a && a[c++];
+ }
+ a = 1;
+ g();
+ })();
+ console.log(c);
+ }
+ expect_stdout: "1"
+}
+
+issue_3113_3: {
+ options = {
+ evaluate: true,
+ inline: true,
+ passes: 2,
+ pure_getters: "strict",
+ reduce_vars: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ var c = 0;
+ (function() {
+ function f() {
+ while (g());
+ }
+ var a;
+ function g() {
+ a && a[c++];
+ }
+ g(a = 1);
+ })();
+ console.log(c);
+ }
+ expect: {
+ var c = 0;
+ c++;
+ console.log(c);
+ }
+ expect_stdout: "1"
+}