From edc60ed80881d43767eeedbe3e58becca08db116 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Mon, 8 Dec 2014 23:46:30 -0800 Subject: [PATCH] Fix invariant issues. --- src/compiler/parser.ts | 4 ++++ src/harness/test262Runner.ts | 42 +++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 588b1f53974..bc91227f381 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -293,6 +293,7 @@ module ts { case SyntaxKind.FunctionDeclaration: case SyntaxKind.ArrowFunction: return children(node.modifiers) || + child((node).asteriskToken) || child((node).name) || child((node).questionToken) || children((node).typeParameters) || @@ -345,6 +346,9 @@ module ts { return child((node).expression); case SyntaxKind.PrefixUnaryExpression: return child((node).operand); + case SyntaxKind.YieldExpression: + return child((node).asteriskToken) || + child((node).expression); case SyntaxKind.PostfixUnaryExpression: return child((node).operand); case SyntaxKind.BinaryExpression: diff --git a/src/harness/test262Runner.ts b/src/harness/test262Runner.ts index 547cc48a617..a29c6ac8619 100644 --- a/src/harness/test262Runner.ts +++ b/src/harness/test262Runner.ts @@ -35,15 +35,55 @@ class Test262BaselineRunner extends RunnerBase { if (node.parent !== parent) { throw new Error("node.parent !== parent"); } + if (parent) { + // Make sure each child is contained within the parent. + if (node.pos < parent.pos) { + throw new Error("node.pos < parent.pos"); + } + if (node.end > parent.end) { + throw new Error("node.end > parent.end"); + } + } + ts.forEachChild(node, child => { Test262BaselineRunner.checkInvariants(child, node); }); + // Make sure each of the children is in order. + var currentPos = 0; + ts.forEachChild(node, + child => { + if (child.pos < currentPos) { + throw new Error("child.pos < currentPos"); + } + currentPos = child.end; + }, + (array: ts.NodeArray) => { + if (array.pos < node.pos) { + throw new Error("array.pos < node.pos"); + } + if (array.end > node.end) { + throw new Error("array.end > node.end"); + } + + if (array.pos < currentPos) { + throw new Error("array.pos < currentPos"); + } + for (var i = 0, n = array.length; i < n; i++) { + if (array[i].pos < currentPos) { + throw new Error("array[i].pos < currentPos"); + } + currentPos = array[i].end + } + + currentPos = array.end; + }); + var childNodesAndArrays: any[] = []; ts.forEachChild(node, child => { childNodesAndArrays.push(child) }, array => { childNodesAndArrays.push(array) }); for (var childName in node) { - if (childName === "parent" || childName === "nextContainer" || childName === "modifiers") { + if (childName === "parent" || childName === "nextContainer" || childName === "modifiers" || childName === "externalModuleIndicator") { continue; } var child = (node)[childName];