drop unused "class" definition IIFEs (#2923)

fixes #805
This commit is contained in:
Alex Lam S.L
2018-02-17 05:11:31 +08:00
committed by GitHub
parent e529f54e90
commit 7fdd2082a6
4 changed files with 124 additions and 15 deletions

View File

@@ -4619,3 +4619,26 @@ issue_2914_2: {
}
expect_stdout: "0"
}
issue_805: {
options = {
collapse_vars: true,
pure_getters: "strict",
reduce_vars: true,
}
input: {
function f() {
function Foo(){}
Foo.prototype = {};
Foo.prototype.bar = 42;
return Foo;
}
}
expect: {
function f() {
function Foo(){}
(Foo.prototype = {}).bar = 42;
return Foo;
}
}
}

View File

@@ -1719,3 +1719,69 @@ issue_2846: {
}
expect_stdout: "0"
}
issue_805_1: {
options = {
inline: true,
passes: 2,
pure_getters: "strict",
reduce_vars: true,
sequences: true,
side_effects: true,
unused: true,
}
input: {
(function(a) {
var unused = function() {};
unused.prototype[a()] = 42;
(unused.prototype.bar = function() {
console.log("bar");
})();
return unused;
})(function() {
console.log("foo");
return "foo";
});
}
expect: {
console.log("foo"),
console.log("bar");
}
expect_stdout: [
"foo",
"bar",
]
}
issue_805_2: {
options = {
inline: true,
passes: 2,
pure_getters: "strict",
reduce_vars: true,
sequences: true,
side_effects: true,
unused: true,
}
input: {
(function(a) {
function unused() {}
unused.prototype[a()] = 42;
(unused.prototype.bar = function() {
console.log("bar");
})();
return unused;
})(function() {
console.log("foo");
return "foo";
});
}
expect: {
console.log("foo"),
console.log("bar");
}
expect_stdout: [
"foo",
"bar",
]
}

View File

@@ -38,7 +38,7 @@ describe("test/jetstream.js", function() {
this.timeout(20 * 60 * 1000);
[
"-mc",
"-mc keep_fargs=false,passes=3,pure_getters,unsafe,unsafe_comps,unsafe_math,unsafe_proto",
"-mc keep_fargs=false,passes=3,unsafe,unsafe_comps,unsafe_math,unsafe_proto",
].forEach(function(options) {
it("Should pass with options " + options, function(done) {
var args = options.split(/ /);