158 lines
2.9 KiB
JavaScript
158 lines
2.9 KiB
JavaScript
|
|
issue_2377_1: {
|
||
|
|
options = {
|
||
|
|
evaluate: true,
|
||
|
|
inline: true,
|
||
|
|
hoist_props: true,
|
||
|
|
reduce_vars: true,
|
||
|
|
toplevel: true,
|
||
|
|
unused: true,
|
||
|
|
}
|
||
|
|
mangle = {
|
||
|
|
toplevel: true,
|
||
|
|
}
|
||
|
|
input: {
|
||
|
|
var obj = {
|
||
|
|
foo: 1,
|
||
|
|
bar: 2,
|
||
|
|
square: function(x) {
|
||
|
|
return x * x;
|
||
|
|
},
|
||
|
|
cube: function(x) {
|
||
|
|
return x * x * x;
|
||
|
|
},
|
||
|
|
};
|
||
|
|
console.log(obj.foo, obj.cube(3));
|
||
|
|
}
|
||
|
|
expect: {
|
||
|
|
var n = 1, o = function(n) {
|
||
|
|
return n * n * n;
|
||
|
|
};
|
||
|
|
console.log(n, o(3));
|
||
|
|
}
|
||
|
|
expect_stdout: "1 27"
|
||
|
|
}
|
||
|
|
|
||
|
|
issue_2377_2: {
|
||
|
|
options = {
|
||
|
|
evaluate: true,
|
||
|
|
inline: true,
|
||
|
|
hoist_props: true,
|
||
|
|
passes: 2,
|
||
|
|
reduce_vars: true,
|
||
|
|
toplevel: true,
|
||
|
|
unused: true,
|
||
|
|
}
|
||
|
|
mangle = {
|
||
|
|
toplevel: true,
|
||
|
|
}
|
||
|
|
input: {
|
||
|
|
var obj = {
|
||
|
|
foo: 1,
|
||
|
|
bar: 2,
|
||
|
|
square: function(x) {
|
||
|
|
return x * x;
|
||
|
|
},
|
||
|
|
cube: function(x) {
|
||
|
|
return x * x * x;
|
||
|
|
},
|
||
|
|
};
|
||
|
|
console.log(obj.foo, obj.cube(3));
|
||
|
|
}
|
||
|
|
expect: {
|
||
|
|
console.log(1, function(n) {
|
||
|
|
return n * n * n;
|
||
|
|
}(3));
|
||
|
|
}
|
||
|
|
expect_stdout: "1 27"
|
||
|
|
}
|
||
|
|
|
||
|
|
issue_2377_3: {
|
||
|
|
options = {
|
||
|
|
evaluate: true,
|
||
|
|
inline: true,
|
||
|
|
hoist_props: true,
|
||
|
|
passes: 3,
|
||
|
|
reduce_vars: true,
|
||
|
|
toplevel: true,
|
||
|
|
unused: true,
|
||
|
|
}
|
||
|
|
mangle = {
|
||
|
|
toplevel: true,
|
||
|
|
}
|
||
|
|
input: {
|
||
|
|
var obj = {
|
||
|
|
foo: 1,
|
||
|
|
bar: 2,
|
||
|
|
square: function(x) {
|
||
|
|
return x * x;
|
||
|
|
},
|
||
|
|
cube: function(x) {
|
||
|
|
return x * x * x;
|
||
|
|
},
|
||
|
|
};
|
||
|
|
console.log(obj.foo, obj.cube(3));
|
||
|
|
}
|
||
|
|
expect: {
|
||
|
|
console.log(1, 27);
|
||
|
|
}
|
||
|
|
expect_stdout: "1 27"
|
||
|
|
}
|
||
|
|
|
||
|
|
direct_access: {
|
||
|
|
options = {
|
||
|
|
reduce_vars: true,
|
||
|
|
hoist_props: true,
|
||
|
|
toplevel: true,
|
||
|
|
unused: true,
|
||
|
|
}
|
||
|
|
mangle = {
|
||
|
|
toplevel: true,
|
||
|
|
}
|
||
|
|
input: {
|
||
|
|
var a = 0;
|
||
|
|
var obj = {
|
||
|
|
a: 1,
|
||
|
|
b: 2,
|
||
|
|
};
|
||
|
|
for (var k in obj) a++;
|
||
|
|
console.log(a, obj.a);
|
||
|
|
}
|
||
|
|
expect: {
|
||
|
|
var a = 0;
|
||
|
|
var o = {
|
||
|
|
a: 1,
|
||
|
|
b: 2,
|
||
|
|
};
|
||
|
|
for (var r in o) a++;
|
||
|
|
console.log(a, o.a);
|
||
|
|
}
|
||
|
|
expect_stdout: "2 1"
|
||
|
|
}
|
||
|
|
|
||
|
|
single_use: {
|
||
|
|
options = {
|
||
|
|
reduce_vars: true,
|
||
|
|
hoist_props: true,
|
||
|
|
toplevel: true,
|
||
|
|
unused: true,
|
||
|
|
}
|
||
|
|
mangle = {
|
||
|
|
toplevel: true,
|
||
|
|
}
|
||
|
|
input: {
|
||
|
|
var obj = {
|
||
|
|
bar: function() {
|
||
|
|
return 42;
|
||
|
|
},
|
||
|
|
};
|
||
|
|
console.log(obj.bar());
|
||
|
|
}
|
||
|
|
expect: {
|
||
|
|
console.log({
|
||
|
|
bar: function() {
|
||
|
|
return 42;
|
||
|
|
},
|
||
|
|
}.bar());
|
||
|
|
}
|
||
|
|
}
|