@@ -180,6 +180,26 @@ collapse_arg_sequence: {
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
collapse_in_arg: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
keep_fargs: false,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
(function(a, b = a) {
|
||||
b("PASS");
|
||||
})(console.log);
|
||||
}
|
||||
expect: {
|
||||
(function(a) {
|
||||
a("PASS");
|
||||
})(console.log);
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
collapse_value_1: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
@@ -2872,3 +2892,127 @@ issue_5536: {
|
||||
expect_stdout: "undefined"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
issue_5566_1: {
|
||||
options = {
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
(function(a, f = function() {
|
||||
return a;
|
||||
}) {
|
||||
var a = "foo";
|
||||
console.log(a, f());
|
||||
})("bar");
|
||||
}
|
||||
expect: {
|
||||
(function(a, f = function() {
|
||||
return a;
|
||||
}) {
|
||||
var a = "foo";
|
||||
console.log(a, f());
|
||||
})("bar");
|
||||
}
|
||||
expect_stdout: "foo bar"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
issue_5566_2: {
|
||||
options = {
|
||||
inline: true,
|
||||
reduce_vars: true,
|
||||
}
|
||||
input: {
|
||||
(function(a, f = function() {
|
||||
return a;
|
||||
}) {
|
||||
function a() {}
|
||||
console.log(typeof a, typeof f());
|
||||
})(42);
|
||||
}
|
||||
expect: {
|
||||
(function(a, f = function() {
|
||||
return a;
|
||||
}) {
|
||||
function a() {}
|
||||
console.log(typeof a, typeof f());
|
||||
})(42);
|
||||
}
|
||||
expect_stdout: "function number"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
issue_5566_3: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
(function(a, f = function() {
|
||||
return a;
|
||||
}) {
|
||||
function a() {}
|
||||
console.log(typeof a, typeof f());
|
||||
})(42);
|
||||
}
|
||||
expect: {
|
||||
(function(a, f = function() {
|
||||
return a;
|
||||
}) {
|
||||
function a() {}
|
||||
console.log(typeof a, typeof f());
|
||||
})(42);
|
||||
}
|
||||
expect_stdout: "function number"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
issue_5566_4: {
|
||||
options = {
|
||||
collapse_vars: true,
|
||||
unused: true,
|
||||
}
|
||||
input: {
|
||||
(function(a, b = function() {
|
||||
return a;
|
||||
}) {
|
||||
var a = 0;
|
||||
b()("PASS");
|
||||
})(console.log);
|
||||
}
|
||||
expect: {
|
||||
(function(a, b = function() {
|
||||
return a;
|
||||
}) {
|
||||
var a = 0;
|
||||
b()("PASS");
|
||||
})(console.log);
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
issue_5566_5: {
|
||||
options = {
|
||||
hoist_vars: true,
|
||||
}
|
||||
input: {
|
||||
(function(a, f = function() {
|
||||
return a;
|
||||
}) {
|
||||
var a = "foo";
|
||||
var b;
|
||||
console.log(a, f());
|
||||
})("bar");
|
||||
}
|
||||
expect: {
|
||||
(function(a, f = function() {
|
||||
return a;
|
||||
}) {
|
||||
var b, a = "foo";
|
||||
console.log(a, f());
|
||||
})("bar");
|
||||
}
|
||||
expect_stdout: "foo bar"
|
||||
node_version: ">=6"
|
||||
}
|
||||
|
||||
@@ -241,23 +241,6 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
||||
CHANGED = true;
|
||||
return node.name;
|
||||
}
|
||||
else if (node instanceof U.AST_DestructuredArray) {
|
||||
var expr = node.elements[0];
|
||||
if (expr && !(expr instanceof U.AST_Hole)) {
|
||||
node.start._permute++;
|
||||
CHANGED = true;
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
else if (node instanceof U.AST_DestructuredObject) {
|
||||
// first property's value
|
||||
var expr = node.properties[0];
|
||||
if (expr) {
|
||||
node.start._permute++;
|
||||
CHANGED = true;
|
||||
return expr.value;
|
||||
}
|
||||
}
|
||||
else if (node instanceof U.AST_Defun) {
|
||||
switch (((node.start._permute += step) * steps | 0) % 2) {
|
||||
case 0:
|
||||
@@ -275,6 +258,23 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (node instanceof U.AST_DestructuredArray) {
|
||||
var expr = node.elements[0];
|
||||
if (expr && !(expr instanceof U.AST_Hole)) {
|
||||
node.start._permute++;
|
||||
CHANGED = true;
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
else if (node instanceof U.AST_DestructuredObject) {
|
||||
// first property's value
|
||||
var expr = node.properties[0];
|
||||
if (expr) {
|
||||
node.start._permute++;
|
||||
CHANGED = true;
|
||||
return expr.value;
|
||||
}
|
||||
}
|
||||
else if (node instanceof U.AST_DWLoop) {
|
||||
var expr = [
|
||||
node.condition,
|
||||
@@ -296,6 +296,16 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
||||
return to_statement(expr);
|
||||
}
|
||||
}
|
||||
else if (node instanceof U.AST_ExportDeclaration) {
|
||||
node.start._permute++;
|
||||
CHANGED = true;
|
||||
return node.body;
|
||||
}
|
||||
else if (node instanceof U.AST_ExportDefault) {
|
||||
node.start._permute++;
|
||||
CHANGED = true;
|
||||
return to_statement(node.body);
|
||||
}
|
||||
else if (node instanceof U.AST_Finally) {
|
||||
// drop finally block
|
||||
node.start._permute++;
|
||||
@@ -351,6 +361,15 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
||||
return to_statement(expr);
|
||||
}
|
||||
}
|
||||
else if (node instanceof U.AST_LabeledStatement) {
|
||||
if (node.body instanceof U.AST_Statement
|
||||
&& !has_loopcontrol(node.body, node.body, node)) {
|
||||
// replace labelled statement with its non-labelled body
|
||||
node.start._permute = REPLACEMENTS.length;
|
||||
CHANGED = true;
|
||||
return node.body;
|
||||
}
|
||||
}
|
||||
else if (node instanceof U.AST_Object) {
|
||||
// first property's value
|
||||
var expr = node.properties[0];
|
||||
@@ -441,15 +460,6 @@ module.exports = function reduce_test(testcase, minify_options, reduce_options)
|
||||
return to_statement(node.definitions[0].value);
|
||||
}
|
||||
}
|
||||
else if (node instanceof U.AST_LabeledStatement) {
|
||||
if (node.body instanceof U.AST_Statement
|
||||
&& !has_loopcontrol(node.body, node.body, node)) {
|
||||
// replace labelled statement with its non-labelled body
|
||||
node.start._permute = REPLACEMENTS.length;
|
||||
CHANGED = true;
|
||||
return node.body;
|
||||
}
|
||||
}
|
||||
|
||||
if (in_list) {
|
||||
// drop switch branches
|
||||
|
||||
Reference in New Issue
Block a user