Merge branch 'master' into harmony-v3.1.10

This commit is contained in:
alexlamsl
2017-11-19 14:34:27 +08:00
10 changed files with 935 additions and 232 deletions

View File

@@ -3400,3 +3400,483 @@ issue_2453: {
}
expect_stdout: "42"
}
issue_2436_1: {
options = {
collapse_vars: true,
inline: true,
pure_getters: "strict",
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var o = {
a: 1,
b: 2,
};
console.log(function(c) {
return {
x: c.a,
y: c.b,
};
}(o));
}
expect: {
var o = {
a: 1,
b: 2,
};
console.log({
x: o.a,
y: o.b,
});
}
expect_stdout: true
}
issue_2436_2: {
options = {
collapse_vars: true,
inline: true,
pure_getters: "strict",
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var o = {
a: 1,
b: 2,
};
console.log(function(c) {
o.a = 3;
return {
x: c.a,
y: c.b,
};
}(o));
}
expect: {
var o = {
a: 1,
b: 2,
};
console.log(function(c) {
o.a = 3;
return {
x: c.a,
y: c.b,
};
}(o));
}
expect_stdout: true
}
issue_2436_3: {
options = {
collapse_vars: true,
inline: true,
pure_getters: "strict",
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var o = {
a: 1,
b: 2,
};
console.log(function(c) {
o = {
a: 3,
b: 4,
};
return {
x: c.a,
y: c.b,
};
}(o));
}
expect: {
var o = {
a: 1,
b: 2,
};
console.log(function(c) {
o = {
a: 3,
b: 4,
};
return {
x: c.a,
y: c.b,
};
}(o));
}
expect_stdout: true
}
issue_2436_4: {
options = {
collapse_vars: true,
inline: true,
pure_getters: "strict",
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var o = {
a: 1,
b: 2,
};
console.log(function(c) {
return {
x: c.a,
y: c.b,
};
var o;
}(o));
}
expect: {
console.log(function(c) {
return {
x: c.a,
y: c.b,
};
}({
a: 1,
b: 2,
}));
}
expect_stdout: true
}
issue_2436_5: {
options = {
collapse_vars: true,
inline: true,
pure_getters: "strict",
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var o = {
a: 1,
b: 2,
};
console.log(function(o) {
return {
x: o.a,
y: o.b,
};
}(o));
}
expect: {
console.log(function(o) {
return {
x: o.a,
y: o.b,
};
}({
a: 1,
b: 2,
}));
}
expect_stdout: true
}
issue_2436_6: {
options = {
collapse_vars: true,
evaluate: true,
inline: true,
passes: 2,
pure_getters: "strict",
reduce_vars: true,
toplevel: true,
unused: true,
unsafe: true,
}
input: {
var o = {
a: 1,
b: 2,
};
console.log(function(c) {
return {
x: c.a,
y: c.b,
};
}(o));
}
expect: {
console.log({
x: 1,
y: 2,
});
}
expect_stdout: true
}
issue_2436_7: {
options = {
collapse_vars: true,
hoist_props: true,
inline: true,
passes: 3,
pure_getters: "strict",
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var o = {
a: 1,
b: 2,
};
console.log(function(c) {
return {
x: c.a,
y: c.b,
};
}(o));
}
expect: {
console.log({
x: 1,
y: 2,
});
}
expect_stdout: true
}
issue_2436_8: {
options = {
collapse_vars: true,
inline: true,
pure_getters: "strict",
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
console.log(function(c) {
return {
x: c.a,
y: c.b,
};
}(o));
}
expect: {
console.log(function(c) {
return {
x: c.a,
y: c.b,
};
}(o));
}
expect_stdout: true
}
issue_2436_9: {
options = {
collapse_vars: true,
inline: true,
pure_getters: "strict",
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var o = console;
console.log(function(c) {
return {
x: c.a,
y: c.b,
};
}(o));
}
expect: {
var o = console;
console.log(function(c) {
return {
x: c.a,
y: c.b,
};
}(o));
}
expect_stdout: true
}
issue_2436_10: {
options = {
collapse_vars: true,
inline: true,
pure_getters: true,
reduce_vars: true,
toplevel: true,
unused: true,
}
input: {
var o = {
a: 1,
b: 2,
};
function f(n) {
o = { b: 3 };
return n;
}
console.log(function(c) {
return [
c.a,
f(c.b),
c.b,
];
}(o).join(" "));
}
expect: {
var o = {
a: 1,
b: 2,
};
function f(n) {
o = { b: 3 };
return n;
}
console.log(function(c) {
return [
c.a,
f(c.b),
c.b,
];
}(o).join(" "));
}
expect_stdout: "1 2 2"
}
issue_2436_11: {
options = {
collapse_vars: true,
join_vars: true,
reduce_vars: true,
unused: true,
}
input: {
function matrix() {}
function isCollection() {}
function _randomDataForMatrix() {}
function _randomInt() {}
function f(arg1, arg2) {
if (isCollection(arg1)) {
var size = arg1;
var max = arg2;
var min = 0;
var res = _randomDataForMatrix(size.valueOf(), min, max, _randomInt);
return size && true === size.isMatrix ? matrix(res) : res;
} else {
var min = arg1;
var max = arg2;
return _randomInt(min, max);
}
}
}
expect: {
function matrix() {}
function isCollection() {}
function _randomDataForMatrix() {}
function _randomInt() {}
function f(arg1, arg2) {
if (isCollection(arg1)) {
var size = arg1, max = arg2, min = 0, res = _randomDataForMatrix(size.valueOf(), min, max, _randomInt);
return size && true === size.isMatrix ? matrix(res) : res;
} else {
return _randomInt(min = arg1, max = arg2);
}
}
}
}
issue_2436_12: {
options = {
collapse_vars: true,
unused: true,
}
input: {
function isUndefined() {}
function f() {
var viewValue = this.$$lastCommittedViewValue;
var modelValue = viewValue;
return isUndefined(modelValue) ? modelValue : null;
}
}
expect: {
function isUndefined() {}
function f() {
var modelValue = this.$$lastCommittedViewValue;
return isUndefined(modelValue) ? modelValue : null;
}
}
}
issue_2436_13: {
options = {
collapse_vars: true,
reduce_vars: true,
unused: true,
}
input: {
var a = "PASS";
(function() {
function f(b) {
(function g(b) {
var b = b && (b.null = "FAIL");
})(a);
}
f();
})();
console.log(a);
}
expect: {
var a = "PASS";
(function() {
(function(b) {
(function(b) {
a && (a.null = "FAIL");
})();
})();
})();
console.log(a);
}
expect_stdout: "PASS"
}
issue_2436_14: {
options = {
collapse_vars: true,
reduce_vars: true,
unused: true,
}
input: {
var a = "PASS";
var b = {};
(function() {
var c = a;
c && function(c, d) {
console.log(c, d);
}(b, c);
})();
}
expect: {
var a = "PASS";
var b = {};
(function() {
a && function(c, d) {
console.log(c, d);
}(b, a);
})();
}
expect_stdout: true
}

View File

@@ -548,3 +548,92 @@ issue_2462: {
};
}
}
issue_2473_1: {
options = {
hoist_props: false,
reduce_vars: true,
top_retain: [ "x", "y" ],
toplevel: true,
unused: true,
}
input: {
var x = {};
var y = [];
var z = {};
}
expect: {
var x = {};
var y = [];
}
}
issue_2473_2: {
options = {
hoist_props: true,
reduce_vars: true,
top_retain: [ "x", "y" ],
toplevel: true,
unused: true,
}
input: {
var x = {};
var y = [];
var z = {};
}
expect: {
var x = {};
var y = [];
}
}
issue_2473_3: {
options = {
hoist_props: true,
reduce_vars: true,
top_retain: "o",
toplevel: true,
unused: true,
}
input: {
var o = {
a: 1,
b: 2,
};
console.log(o.a, o.b);
}
expect: {
var o = {
a: 1,
b: 2,
};
console.log(o.a, o.b);
}
expect_stdout: "1 2"
}
issue_2473_4: {
options = {
hoist_props: true,
reduce_vars: true,
top_retain: "o",
toplevel: true,
unused: true,
}
input: {
(function() {
var o = {
a: 1,
b: 2,
};
console.log(o.a, o.b);
})();
}
expect: {
(function() {
var o_a = 1, o_b = 2;
console.log(o_a, o_b);
})();
}
expect_stdout: "1 2"
}

View File

@@ -4771,3 +4771,51 @@ perf_8: {
}
expect_stdout: "348150"
}
issue_2485: {
options = {
reduce_funcs: true,
reduce_vars: true,
unused: true,
}
input: {
var foo = function(bar) {
var n = function(a, b) {
return a + b;
};
var sumAll = function(arg) {
return arg.reduce(n, 0);
};
var runSumAll = function(arg) {
return sumAll(arg);
};
bar.baz = function(arg) {
var n = runSumAll(arg);
return (n.get = 1), n;
};
return bar;
};
var bar = foo({});
console.log(bar.baz([1, 2, 3]));
}
expect: {
var foo = function(bar) {
var n = function(a, b) {
return a + b;
};
var runSumAll = function(arg) {
return function(arg) {
return arg.reduce(n, 0);
}(arg);
};
bar.baz = function(arg) {
var n = runSumAll(arg);
return (n.get = 1), n;
};
return bar;
};
var bar = foo({});
console.log(bar.baz([1, 2, 3]));
}
expect_stdout: "6"
}