support asynchronous test cases properly (#4529)

This commit is contained in:
Alex Lam S.L
2021-01-19 23:27:32 +00:00
committed by GitHub
parent 7793c6c389
commit d37ee4d41c
10 changed files with 369 additions and 156 deletions

View File

@@ -382,6 +382,7 @@ merge(Compressor.prototype, {
});
}
var RE_POSITIVE_INTEGER = /^(0|[1-9][0-9]*)$/;
(function(def) {
def(AST_Node, noop);
@@ -603,7 +604,7 @@ merge(Compressor.prototype, {
if (!is_arguments(def)) return;
var key = node.property;
if (key.is_constant()) key = key.value;
if (!(key instanceof AST_Node) && !/^[1-9]*[0-9]$/.test(key)) return;
if (!(key instanceof AST_Node) && !RE_POSITIVE_INTEGER.test(key)) return;
def.reassigned = true;
(key instanceof AST_Node ? def.scope.argnames : [ def.scope.argnames[key] ]).forEach(function(argname) {
if (argname instanceof AST_SymbolFunarg) argname.definition().fixed = false;
@@ -8160,7 +8161,7 @@ merge(Compressor.prototype, {
try {
var code = "n(function(" + self.args.slice(0, -1).map(function(arg) {
return arg.value;
}).join(",") + "){" + self.args[self.args.length - 1].value + "})";
}).join() + "){" + self.args[self.args.length - 1].value + "})";
var ast = parse(code);
var mangle = { ie8: compressor.option("ie8") };
ast.figure_out_scope(mangle);
@@ -8183,7 +8184,7 @@ merge(Compressor.prototype, {
make_node(AST_String, self, {
value: fun.argnames.map(function(arg) {
return arg.print_to_string();
}).join(",")
}).join(),
}),
make_node(AST_String, self.args[self.args.length - 1], {
value: code.get().replace(/^\{|\}$/g, "")
@@ -10846,7 +10847,7 @@ merge(Compressor.prototype, {
flush();
values.push(prop);
}
if (found && !generated && typeof key == "string" && /^[1-9]*[0-9]$/.test(key)) {
if (found && !generated && typeof key == "string" && RE_POSITIVE_INTEGER.test(key)) {
generated = true;
if (keys.has(key)) prop = keys.get(key)[0];
prop.key = make_node(AST_Number, prop, {