diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-10-21 04:08:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-21 04:08:26 +0800 |
commit | c927cea6322788b654128f9bbbf3a06441b964c2 (patch) | |
tree | 774308d30281391b20b17f93aed7db8ba4523c6e /test/compress/reduce_vars.js | |
parent | 9f4b98f8e461dabf3a3c97c247d9c72f981aa28d (diff) | |
download | tracifyjs-c927cea6322788b654128f9bbbf3a06441b964c2.tar.gz tracifyjs-c927cea6322788b654128f9bbbf3a06441b964c2.zip |
`unsafe` fix-ups for #2351 (#2379)
Diffstat (limited to 'test/compress/reduce_vars.js')
-rw-r--r-- | test/compress/reduce_vars.js | 64 |
1 files changed, 62 insertions, 2 deletions
diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index d93f0cd1..a03bc1c8 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -1190,10 +1190,10 @@ defun_label: { !function() { console.log(function(a) { L: { - if (a) break L; + if (2) break L; return 1; } - }(2)); + }()); }(); } expect_stdout: true @@ -2894,3 +2894,63 @@ array_forin_2: { } expect_stdout: "3" } + +const_expr_1: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + unsafe: true, + unused: true, + } + input: { + var o = { + a: 1, + b: 2 + }; + o.a++; + console.log(o.a, o.b); + } + expect: { + var o = { + a: 1, + b: 2 + }; + o.a++; + console.log(o.a, o.b); + } + expect_stdout: "2 2" +} + +const_expr_2: { + options = { + evaluate: true, + reduce_vars: true, + toplevel: true, + unsafe: true, + unused: true, + } + input: { + Object.prototype.c = function() { + this.a++; + }; + var o = { + a: 1, + b: 2 + }; + o.c(); + console.log(o.a, o.b); + } + expect: { + Object.prototype.c = function() { + this.a++; + }; + var o = { + a: 1, + b: 2 + }; + o.c(); + console.log(o.a, o.b); + } + expect_stdout: "2 2" +} |