diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-11-17 04:35:00 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-17 12:35:00 +0800 |
commit | 6dbacb5e3f4b3be40fab132575c2e5e3f820b32f (patch) | |
tree | c99062387272231d92dc598aeaa39fdfe9bce5aa /test/compress | |
parent | e5f80afc53e7df3b0b57931a03dc3481ddd9c30e (diff) | |
download | tracifyjs-6dbacb5e3f4b3be40fab132575c2e5e3f820b32f.tar.gz tracifyjs-6dbacb5e3f4b3be40fab132575c2e5e3f820b32f.zip |
enhance `varify` (#4279)
Diffstat (limited to 'test/compress')
-rw-r--r-- | test/compress/varify.js | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/test/compress/varify.js b/test/compress/varify.js index 1286fc67..d4894d2d 100644 --- a/test/compress/varify.js +++ b/test/compress/varify.js @@ -234,3 +234,122 @@ issue_4191_let: { expect_stdout: "function undefined" node_version: ">=4" } + +forin_const_1: { + options = { + join_vars: true, + reduce_vars: true, + toplevel: true, + varify: true, + } + input: { + const o = { + foo: 42, + bar: "PASS", + }; + for (const k in o) + console.log(k, o[k]); + } + expect: { + var o = { + foo: 42, + bar: "PASS", + }; + for (const k in o) + console.log(k, o[k]); + } + expect_stdout: true + node_version: ">=4" +} + +forin_const_2: { + options = { + join_vars: true, + reduce_vars: true, + toplevel: true, + varify: true, + } + input: { + const o = { + p: 42, + q: "PASS", + }; + for (const [ k ] in o) + console.log(k, o[k]); + } + expect: { + var o = { + p: 42, + q: "PASS", + }, k; + for ([ k ] in o) + console.log(k, o[k]); + } + expect_stdout: [ + "p 42", + "q PASS", + ] + node_version: ">=6" +} + +forin_let_1: { + options = { + join_vars: true, + reduce_vars: true, + toplevel: true, + varify: true, + } + input: { + "use strict"; + let o = { + foo: 42, + bar: "PASS", + }; + for (let k in o) + console.log(k, o[k]); + } + expect: { + "use strict"; + var o = { + foo: 42, + bar: "PASS", + }, k; + for (k in o) + console.log(k, o[k]); + } + expect_stdout: [ + "foo 42", + "bar PASS", + ] + node_version: ">=4" +} + +forin_let_2: { + options = { + join_vars: true, + reduce_vars: true, + toplevel: true, + varify: true, + } + input: { + let o = { + p: 42, + q: "PASS", + }; + for (let [ k ] in o) + console.log(k, o[k]); + } + expect: { + var o = { + p: 42, + q: "PASS", + }, k; + for ([ k ] in o) + console.log(k, o[k]); + } + expect_stdout: [ + "p 42", + "q PASS", + ] + node_version: ">=6" +} |