fix(wasm): allow passing in ERROR in descendantsOfType
This commit is contained in:
parent
95fd37ecf8
commit
cd6e766365
2 changed files with 22 additions and 0 deletions
|
|
@ -494,6 +494,23 @@ describe('Node', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('.descendantsOfType("ERROR", null, null)', () => {
|
||||
it('finds all of the descendants of an ERROR node', () => {
|
||||
tree = parser.parse(
|
||||
`if ({a: 'b'} {c: 'd'}) {
|
||||
// ^ ERROR
|
||||
x = function(a) { b; } function(c) { d; }
|
||||
}`
|
||||
);
|
||||
const errorNode = tree.rootNode;
|
||||
let descendants = errorNode.descendantsOfType('ERROR', null, null);
|
||||
assert.deepEqual(
|
||||
descendants.map((node) => node.startIndex),
|
||||
[4],
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('.descendantsOfType(type, min, max)', () => {
|
||||
it('finds all of the descendants of the given type in the given range', () => {
|
||||
tree = parser.parse('a + 1 * b * 2 + c + 3');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue