Conflicts:
	acorn.js
This commit is contained in:
Sebastian McKenzie 2015-01-04 22:03:02 +11:00
commit 29a4dcc975
2 changed files with 87 additions and 0 deletions

View File

@ -1863,6 +1863,14 @@
}
break;
case "AssignmentExpression":
if (node.operator === "=") {
node.type = "AssignmentPattern";
} else {
unexpected(node.left.end);
}
break;
default:
if (checkType) unexpected(node.start);
}
@ -1963,6 +1971,7 @@
break;
case "SpreadProperty":
case "AssignmentPattern":
case "SpreadElement":
case "VirtualPropertyExpression":
break;

View File

@ -14388,3 +14388,81 @@ test('var {get} = obj;', {
kind: "var"
}]
}, {ecmaVersion: 6});
// Destructuring defaults (https://github.com/marijnh/acorn/issues/181)
test("var {propName: localVar = defaultValue} = obj", {
type: "Program",
body: [{
type: "VariableDeclaration",
declarations: [{
type: "VariableDeclarator",
id: {
type: "ObjectPattern",
properties: [{
type: "Property",
method: false,
shorthand: false,
computed: false,
key: {
type: "Identifier",
name: "propName"
},
value: {
type: "AssignmentPattern",
operator: "=",
left: {
type: "Identifier",
name: "localVar"
},
right: {
type: "Identifier",
name: "defaultValue"
}
},
kind: "init"
}]
},
init: {
type: "Identifier",
name: "obj"
}
}],
kind: "var"
}]
}, {ecmaVersion: 6});
test("var [a = 1, b = 2] = arr", {
type: "Program",
body: [{
type: "VariableDeclaration",
declarations: [{
type: "VariableDeclarator",
id: {
type: "ArrayPattern",
elements: [
{
type: "AssignmentPattern",
operator: "=",
left: {type: "Identifier", name: "a"},
right: {
type: "Literal",
value: 1
}
},
{
type: "AssignmentPattern",
operator: "=",
left: {type: "Identifier", name: "b"},
right: {
type: "Literal",
value: 2
}
}
]
},
init: {type: "Identifier", name: "arr"}
}],
kind: "var"
}]
}, {ecmaVersion: 6});