From 352a7de2041b0a23cf014fe2914af641d9f73436 Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Sun, 5 Nov 2017 15:59:34 +0800 Subject: [PATCH] update tests --- test/compress/arrow.js | 30 +++++++++---------------- test/compress/reduce_vars.js | 43 ++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 20 deletions(-) diff --git a/test/compress/arrow.js b/test/compress/arrow.js index 6df86d49..b9d884f5 100644 --- a/test/compress/arrow.js +++ b/test/compress/arrow.js @@ -314,17 +314,12 @@ issue_2105_1: { }); } expect: { - (() => { - var quux = () => { + ({ + prop() { + console.log; console.log("PASS"); - }; - return { - prop() { - console.log; - quux(); - } - }; - })().prop(); + } + }).prop(); } expect_stdout: "PASS" node_version: ">=4" @@ -360,17 +355,12 @@ issue_2105_2: { }); } expect: { - (() => { - var quux = () => { + ({ + prop: () => { + console.log; console.log("PASS"); - }; - return { - prop: () => { - console.log; - quux(); - } - }; - })().prop(); + } + }).prop(); } expect_stdout: "PASS" node_version: ">=6" diff --git a/test/compress/reduce_vars.js b/test/compress/reduce_vars.js index f0b1264f..04c1e8b2 100644 --- a/test/compress/reduce_vars.js +++ b/test/compress/reduce_vars.js @@ -3622,6 +3622,49 @@ issue_2420_2: { ] } +issue_2420_3: { + options = { + reduce_vars: true, + unused: true, + } + input: { + function f() { + var that = this; + if (that.bar) + that.foo(); + else + ((that, self) => { + console.log(this === that, self === this, that === self); + })(that, this); + } + f.call({ + bar: 1, + foo: function() { console.log("foo", this.bar); }, + }); + f.call({}); + } + expect: { + function f() { + if (this.bar) + this.foo(); + else + ((that, self) => { + console.log(this === that, self === this, that === self); + })(this, this); + } + f.call({ + bar: 1, + foo: function() { console.log("foo", this.bar); }, + }); + f.call({}); + } + expect_stdout: [ + "foo 1", + "true true true", + ] + node_version: ">=4" +} + issue_2423_1: { options = { reduce_vars: true,