Add a test to verify that destructuring arguments work with #203 code
This commit is contained in:
committed by
Richard van Velzen
parent
96b89e34a3
commit
ad344c5be3
@@ -1802,7 +1802,6 @@ merge(Compressor.prototype, {
|
||||
if (ex !== ast) throw ex;
|
||||
};
|
||||
if (!fun) return self;
|
||||
// TODO does this work with destructuring? Test it.
|
||||
var args = fun.argnames.map(function(arg, i){
|
||||
return make_node(AST_String, self.args[i], {
|
||||
value: arg.print_to_string()
|
||||
|
||||
30
test/compress/issue-203.js
Normal file
30
test/compress/issue-203.js
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
compress_new_function: {
|
||||
options = {
|
||||
unsafe: true
|
||||
}
|
||||
input: {
|
||||
new Function("aa, bb", 'return aa;');
|
||||
}
|
||||
expect: {
|
||||
Function("a", "b", "return a");
|
||||
}
|
||||
}
|
||||
|
||||
compress_new_function_with_destruct: {
|
||||
options = {
|
||||
unsafe: true
|
||||
}
|
||||
input: {
|
||||
new Function("aa, [bb]", 'return aa;');
|
||||
new Function("aa, {bb}", 'return aa;');
|
||||
new Function("[[aa]], [{bb}]", 'return aa;');
|
||||
}
|
||||
expect: {
|
||||
Function("a", "[b]", "return a");
|
||||
Function("a", "{bb}", "return a");
|
||||
Function("[[a]]", "[{bb}]", 'return a');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user