implement object rest/spread (#2265)
- improve parse errors for destructuring spread elements - `unsafe` for object literals with rest elements Miscellaneous - increase mocha unicode surrogate test timeout
This commit is contained in:
@@ -253,13 +253,19 @@ describe("Left-hand side expressions", function () {
|
||||
// Multiple spreads are not allowed in destructuring array
|
||||
expect("[...a, ...b] = [1, 2, 3, 4]", "Spread must the be last element in destructuring array");
|
||||
|
||||
// Spread in obvious object pattern
|
||||
expect("({...a} = foo)", "Unexpected token: expand (...)");
|
||||
// Array spread must be last in destructuring declaration
|
||||
expect("let [ ...x, a ] = o;", "Rest element must be last element");
|
||||
|
||||
// Only one spread per destructuring array declaration
|
||||
expect("let [ a, ...x, ...y ] = o;", "Rest element must be last element");
|
||||
|
||||
// Spread in block should not be allowed
|
||||
expect("{...a} = foo", "Unexpected token: expand (...)");
|
||||
|
||||
// Not in standard yet
|
||||
expect("let foo = {bar: 42}, bar; bar = {...foo}", "Unexpected token: expand (...)");
|
||||
// Object spread must be last in destructuring declaration
|
||||
expect("let { ...x, a } = o;", "Rest element must be last element");
|
||||
|
||||
// Only one spread per destructuring declaration
|
||||
expect("let { a, ...x, ...y } = o;", "Rest element must be last element");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user