aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-03-25 03:18:36 +0800
committerGitHub <noreply@github.com>2017-03-25 03:18:36 +0800
commita30092e20f6a1e23706f87ca998121b8832a57bb (patch)
treebee9a34ae1e686ee724f3e2662e5a808e7f780d7 /test/compress
parentb1abe92e1aface2ec3d1c3666f8674e120f3b487 (diff)
downloadtracifyjs-a30092e20f6a1e23706f87ca998121b8832a57bb.tar.gz
tracifyjs-a30092e20f6a1e23706f87ca998121b8832a57bb.zip
fix invalid `AST_For.init` (#1657)
Turns out the only place in `Compressor` which can generate invalid `AST_For.init` is within `drop_unused()`, so focus the fix-up efforts. supercedes #1652 fixes #1656
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/drop-unused.js14
-rw-r--r--test/compress/issue-1656.js45
2 files changed, 59 insertions, 0 deletions
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index 9f3bf77d..fabf8d9f 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -791,3 +791,17 @@ issue_1583: {
}
}
}
+
+issue_1656: {
+ options = {
+ toplevel: true,
+ unused: true,
+ }
+ beautify = {
+ beautify: true,
+ }
+ input: {
+ for(var a=0;;);
+ }
+ expect_exact: "for (;;) ;"
+}
diff --git a/test/compress/issue-1656.js b/test/compress/issue-1656.js
new file mode 100644
index 00000000..8b683a28
--- /dev/null
+++ b/test/compress/issue-1656.js
@@ -0,0 +1,45 @@
+f7: {
+ options = {
+ booleans: true,
+ cascade: true,
+ collapse_vars: true,
+ comparisons: true,
+ conditionals: true,
+ dead_code: true,
+ drop_debugger: true,
+ evaluate: true,
+ hoist_funs: true,
+ if_return: true,
+ join_vars: true,
+ loops: true,
+ negate_iife: true,
+ passes: 3,
+ properties: true,
+ reduce_vars: true,
+ sequences: true,
+ side_effects: true,
+ toplevel: true,
+ unused: true,
+ }
+ beautify = {
+ beautify: true,
+ }
+ input: {
+ var a = 100, b = 10;
+ function f22464() {
+ var brake146670 = 5;
+ while (((b = a) ? !a : ~a ? null : b += a) && --brake146670 > 0) {
+ }
+ }
+ f22464();
+ console.log(a, b);
+ }
+ expect_exact: [
+ "var a = 100, b = 10;",
+ "",
+ "!function() {",
+ " for (;b = a, !1; ) ;",
+ "}(), console.log(a, b);",
+ ]
+ expect_stdout: true
+}