Skip to content

Commit

Permalink
test(cst): add test for having error node as root node
Browse files Browse the repository at this point in the history
Refs #35
  • Loading branch information
char0n committed Aug 6, 2020
1 parent c6c230d commit 8703814
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,5 +323,19 @@ describe('tree-sitter', function () {
});
});
});

specify('should support having error node as root node', function () {
const parser = new Parser();
parser.setLanguage(JSONLanguage);

const jsonString = '^';
const cst = parser.parse(jsonString);
const ast = transform(cst);

assert.propertyVal(ast.rootNode, 'type', 'error');
assert.propertyVal(ast.rootNode, 'isUnexpected', false);
assert.propertyVal(ast.rootNode.children[0], 'type', 'error');
assert.propertyVal(ast.rootNode.children[0], 'isUnexpected', true);
});
});
});

0 comments on commit 8703814

Please sign in to comment.