aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2018-03-06 00:45:58 +0800
committerGitHub <noreply@github.com>2018-03-06 00:45:58 +0800
commitfe51a91395f3b0a6ab812f3f42746d39efd9e80c (patch)
treed8b2c380890eeb04d9acb1dbb5ffce863e701c7d /test/compress
parent951d87ca9471b2cbbd6b96200484beb421d1a335 (diff)
downloadtracifyjs-fe51a91395f3b0a6ab812f3f42746d39efd9e80c.tar.gz
tracifyjs-fe51a91395f3b0a6ab812f3f42746d39efd9e80c.zip
handle negated constants correctly in `collapse_vars` (#2975)
fixes #2974
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/collapse_vars.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js
index 97efc21b..8b0f033a 100644
--- a/test/compress/collapse_vars.js
+++ b/test/compress/collapse_vars.js
@@ -5207,3 +5207,39 @@ collapse_rhs_undefined: {
}
expect_stdout: "true true true"
}
+
+issue_2974: {
+ options = {
+ booleans: true,
+ collapse_vars: true,
+ evaluate: true,
+ loops: true,
+ passes: 2,
+ pure_getters: "strict",
+ reduce_vars: true,
+ sequences: true,
+ side_effects: true,
+ unused: true,
+ }
+ input: {
+ var c = 0;
+ (function f(b) {
+ var a = 2;
+ do {
+ b && b[b];
+ b && (b.null = -4);
+ c++;
+ } while (b.null && --a > 0);
+ })(true);
+ console.log(c);
+ }
+ expect: {
+ var c = 0;
+ (function(b) {
+ var a = 2;
+ for (; b.null = -4, c++, b.null && --a > 0;);
+ })(!0),
+ console.log(c);
+ }
+ expect_stdout: "1"
+}