compress new function containing this (#2417)

This commit is contained in:
Alex Lam S.L
2017-10-30 23:19:27 +08:00
committed by GitHub
parent 2fd927a7cc
commit a48f87abf2
3 changed files with 61 additions and 13 deletions

View File

@@ -369,3 +369,31 @@ contains_this_3: {
}
expect_stdout: "1 1 true"
}
new_this: {
options = {
evaluate: true,
hoist_props: true,
inline: true,
passes: 2,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var o = {
a: 1,
b: 2,
f: function(a) {
this.b = a;
}
};
console.log(new o.f(o.a).b, o.b);
}
expect: {
console.log(new function(a) {
this.b = a;
}(1).b, 2);
}
expect_stdout: "1 2"
}

View File

@@ -1006,3 +1006,22 @@ array_hole: {
}
expect_stdout: "2 undefined 3"
}
new_this: {
options = {
properties: true,
side_effects: true,
}
input: {
new {
f: function(a) {
this.a = a;
}
}.f(42);
}
expect: {
new function(a) {
this.a = a;
}(42);
}
}