From c927cea6322788b654128f9bbbf3a06441b964c2 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Sat, 21 Oct 2017 04:08:26 +0800 Subject: `unsafe` fix-ups for #2351 (#2379) --- test/compress/reduce_vars.js | 64 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) (limited to 'test/compress/reduce_vars.js') 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" +} -- cgit v1.2.3