diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-03-02 15:33:58 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-02 23:33:58 +0800 |
commit | adcafce04852bb4730e3e699dfdd656dc018cd0f (patch) | |
tree | 3f30430a010b2967022755f58bee570a9876bc3c /test/compress/varify.js | |
parent | b1e05fd48afd9aceaa00cc621a8f6ac22c097398 (diff) | |
download | tracifyjs-adcafce04852bb4730e3e699dfdd656dc018cd0f.tar.gz tracifyjs-adcafce04852bb4730e3e699dfdd656dc018cd0f.zip |
fix corner cases in `varify` (#4719)
Diffstat (limited to 'test/compress/varify.js')
-rw-r--r-- | test/compress/varify.js | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/test/compress/varify.js b/test/compress/varify.js index ab212842..f60c5474 100644 --- a/test/compress/varify.js +++ b/test/compress/varify.js @@ -354,6 +354,92 @@ forin_let_2: { node_version: ">=6" } +loop_scope_1: { + options = { + toplevel: true, + varify: true, + } + input: { + "use strict"; + var o = { foo: 1, bar: 2 }; + for (let i in o) { + console.log(i); + } + for (const j in o) + setTimeout(() => console.log(j), 0); + for (let k in o) + setTimeout(function() { + console.log(k); + }, 0); + } + expect: { + "use strict"; + var o = { foo: 1, bar: 2 }; + for (var i in o) + console.log(i); + for (const j in o) + setTimeout(() => console.log(j), 0); + for (let k in o) + setTimeout(function() { + console.log(k); + }, 0); + } + expect_stdout: [ + "foo", + "bar", + "foo", + "bar", + "foo", + "bar", + ] + node_version: ">=4" +} + +loop_scope_2: { + options = { + reduce_vars: true, + toplevel: true, + varify: true, + } + input: { + "use strict"; + var a = [ "foo", "bar" ]; + for (var i = 0; i < a.length; i++) { + const x = a[i]; + console.log(x); + let y = a[i]; + setTimeout(() => console.log(y), 0); + const z = a[i]; + setTimeout(function() { + console.log(z); + }, 0); + } + } + expect: { + "use strict"; + var a = [ "foo", "bar" ]; + for (var i = 0; i < a.length; i++) { + var x = a[i]; + console.log(x); + let y = a[i]; + setTimeout(() => console.log(y), 0); + const z = a[i]; + setTimeout(function() { + console.log(z); + }, 0); + } + } + expect_stdout: [ + "foo", + "bar", + "foo", + "foo", + "bar", + "bar", + ] + node_version: ">=4" +} + issue_4290_1_const: { options = { reduce_vars: true, |