diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-01-01 00:09:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-01 00:09:26 +0800 |
commit | 673b0716379e261008b6cbf187e6b212104fb69e (patch) | |
tree | 5346618caed4b6e09e9f9131b7d1a359ab893fe0 /test/compress/sequences.js | |
parent | da82fa59a723b22ad5d8dec42cd2ca0d070f2359 (diff) | |
download | tracifyjs-673b0716379e261008b6cbf187e6b212104fb69e.tar.gz tracifyjs-673b0716379e261008b6cbf187e6b212104fb69e.zip |
enhance `join_vars` & `sequences` (#2697)
- nudge declarations without assignments
- within `AST_BlockStatement`
- across `AST_If`
Diffstat (limited to 'test/compress/sequences.js')
-rw-r--r-- | test/compress/sequences.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/compress/sequences.js b/test/compress/sequences.js index 81b06881..3d12fb0b 100644 --- a/test/compress/sequences.js +++ b/test/compress/sequences.js @@ -796,3 +796,66 @@ cascade_assignment_in_return: { } } } + +hoist_defun: { + options = { + join_vars: true, + sequences: true, + } + input: { + x(); + function f() {} + y(); + } + expect: { + function f() {} + x(), y(); + } +} + +hoist_decl: { + options = { + join_vars: true, + sequences: true, + } + input: { + var a; + w(); + var b = x(); + y(); + for (var c; 0;) z(); + var d; + } + expect: { + var a; + w(); + var b = x(), c, d; + for (y(); 0;) z(); + } +} + +for_init_var: { + options = { + join_vars: true, + unused: false, + } + input: { + var a = "PASS"; + (function() { + var b = 42; + for (var c = 5; c > 0;) c--; + a = "FAIL"; + var a; + })(); + console.log(a); + } + expect: { + var a = "PASS"; + (function() { + for (var b = 42, c = 5, a; c > 0;) c--; + a = "FAIL"; + })(); + console.log(a); + } + expect_stdout: "PASS" +} |