diff options
author | Anthony Van de Gejuchte <anthonyvdgent@gmail.com> | 2016-07-14 18:43:50 +0200 |
---|---|---|
committer | Richard van Velzen <rvanvelzen@experty.com> | 2016-07-15 13:20:52 +0200 |
commit | 7eb52d2837c9d77a389457ae84bfddd28f86cf27 (patch) | |
tree | aa45a1daf8314725d838df74c63a56e331fadd62 /test/compress | |
parent | eb63fece2f48be2be5ee1090d7bb94889a12fd80 (diff) | |
download | tracifyjs-7eb52d2837c9d77a389457ae84bfddd28f86cf27.tar.gz tracifyjs-7eb52d2837c9d77a389457ae84bfddd28f86cf27.zip |
Keep const in own scope while compressing
- Fixes #1205
- Fix provided by @kzc
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/loops.js | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/test/compress/loops.js b/test/compress/loops.js index 91aa1c5f..78f618aa 100644 --- a/test/compress/loops.js +++ b/test/compress/loops.js @@ -144,4 +144,46 @@ parse_do_while_without_semicolon: { expect: { do x(); while (false);y(); } -}
\ No newline at end of file +} + + +keep_collapse_const_in_own_block_scope: { + options = { + join_vars: true, + loops: true + } + input: { + var i=2; + const c=5; + while(i--) + console.log(i); + console.log(c); + } + expect: { + var i=2; + const c=5; + for(;i--;) + console.log(i); + console.log(c); + } +} + +keep_collapse_const_in_own_block_scope_2: { + options = { + join_vars: true, + loops: true + } + input: { + const c=5; + var i=2; // Moves to loop, while it did not in previous test + while(i--) + console.log(i); + console.log(c); + } + expect: { + const c=5; + for(var i=2;i--;) + console.log(i); + console.log(c); + } +} |