Fixed unit tests - needed to add new special case for node child validation logic.

This commit is contained in:
Eric Traut 2019-08-23 06:32:36 -07:00
parent ec4131ea43
commit 01535f8fe8

View File

@ -7,7 +7,7 @@
import * as assert from 'assert';
import { ParseTreeWalker } from '../analyzer/parseTreeWalker';
import { AssignmentNode, ParseNode } from '../parser/parseNodes';
import { AssignmentNode, ParseNode, StringListNode } from '../parser/parseNodes';
export class TestWalker extends ParseTreeWalker {
constructor() {
@ -39,7 +39,7 @@ export class TestWalker extends ParseTreeWalker {
children.forEach(child => {
let skipCheck = false;
// There's an exception we need to deal with here. Comment
// There are a few exceptions we need to deal with here. Comment
// annotations can occur outside of an assignment node's range.
if (node instanceof AssignmentNode) {
if (child === node.typeAnnotationComment) {
@ -47,6 +47,12 @@ export class TestWalker extends ParseTreeWalker {
}
}
if (node instanceof StringListNode) {
if (child === node.typeAnnotation) {
skipCheck = true;
}
}
if (!skipCheck) {
// Make sure the child is contained within the parent.
assert(child.start >= node.start && child.end <= node.end);