From 39a907bde3161f74e298a7fc8502fb0f6a05eaed Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Tue, 20 Feb 2018 17:38:40 +0800 Subject: workaround `pure_getters=true` when dropping unused assignments (#2939) fixes #2938 --- test/compress/pure_getters.js | 51 +++++++++++++++++++++++++++++++++++++++++++ test/mocha/release.js | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/compress/pure_getters.js b/test/compress/pure_getters.js index 4e9ae4f4..82229d4b 100644 --- a/test/compress/pure_getters.js +++ b/test/compress/pure_getters.js @@ -721,3 +721,54 @@ issue_2838: { } expect_stdout: "PASS" } + +issue_2938_1: { + options = { + pure_getters: true, + unused: true, + } + input: { + function f(a) { + a.b = "PASS"; + } + var o = {}; + f(o); + console.log(o.b); + } + expect: { + function f(a) { + a.b = "PASS"; + } + var o = {}; + f(o); + console.log(o.b); + } + expect_stdout: "PASS" +} + +issue_2938_2: { + options = { + pure_getters: true, + toplevel: true, + unused: true, + } + input: { + var Parser = function Parser() {}; + var p = Parser.prototype; + p.initialContext = function initialContext() { + console.log("PASS"); + }; + p.braceIsBlock = function() {}; + (new Parser).initialContext(); + } + expect: { + var Parser = function() {}; + var p = Parser.prototype; + p.initialContext = function() { + console.log("PASS"); + }; + p.braceIsBlock = function() {}; + (new Parser).initialContext(); + } + expect_stdout: "PASS" +} diff --git a/test/mocha/release.js b/test/mocha/release.js index 656ade8d..063d0fc7 100644 --- a/test/mocha/release.js +++ b/test/mocha/release.js @@ -38,7 +38,7 @@ describe("test/jetstream.js", function() { this.timeout(20 * 60 * 1000); [ "-mc", - "-mc keep_fargs=false,passes=3,unsafe,unsafe_comps,unsafe_math,unsafe_proto", + "-mc keep_fargs=false,passes=3,pure_getters,unsafe,unsafe_comps,unsafe_math,unsafe_proto", ].forEach(function(options) { it("Should pass with options " + options, function(done) { var args = options.split(/ /); -- cgit v1.2.3