Add parser tests for computed properties

This commit is contained in:
Jason Freeman
2014-11-17 14:38:35 -08:00
parent 9d5c86a11d
commit cf4f34c224
95 changed files with 626 additions and 78 deletions

View File

@@ -4528,14 +4528,12 @@ module ts {
var inStrictMode = (node.parserContextFlags & ParserContextFlags.StrictMode) !== 0;
for (var i = 0, n = node.properties.length; i < n; i++) {
var prop = node.properties[i];
if (prop.kind === SyntaxKind.OmittedExpression || p.name.kind === SyntaxKind.ComputedPropertyName) {
var prop = <Declaration>node.properties[i];
var name = <Identifier>prop.name;
if (prop.kind === SyntaxKind.OmittedExpression || name.kind === SyntaxKind.ComputedPropertyName) {
continue;
}
var p = <Declaration>prop;
var name = <Identifier>p.name;
// ECMA-262 11.1.5 Object Initialiser
// If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
// a.This production is contained in strict code and IsDataDescriptor(previous) is true and
@@ -4545,20 +4543,20 @@ module ts {
// d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true
// and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields
var currentKind: number;
if (p.kind === SyntaxKind.PropertyAssignment) {
if (prop.kind === SyntaxKind.PropertyAssignment) {
currentKind = Property;
}
else if (p.kind === SyntaxKind.ShorthandPropertyAssignment) {
else if (prop.kind === SyntaxKind.ShorthandPropertyAssignment) {
currentKind = Property;
}
else if (p.kind === SyntaxKind.GetAccessor) {
else if (prop.kind === SyntaxKind.GetAccessor) {
currentKind = GetAccessor;
}
else if (p.kind === SyntaxKind.SetAccessor) {
else if (prop.kind === SyntaxKind.SetAccessor) {
currentKind = SetAccesor;
}
else {
Debug.fail("Unexpected syntax kind:" + p.kind);
Debug.fail("Unexpected syntax kind:" + prop.kind);
}
if (!hasProperty(seen, name.text)) {