Fix bugs in binary search used in tree queries
This commit is contained in:
parent
52cda5f541
commit
60467ae701
3 changed files with 51 additions and 8 deletions
|
|
@ -32,8 +32,9 @@ describe("Query", () => {
|
|||
|
||||
it('matches simple queries', () => {
|
||||
tree = parser.parse("function one() { two(); function three() {} }");
|
||||
const query = JavaScript.query(`
|
||||
(function_declaration name:(identifier) @the-name)
|
||||
query = JavaScript.query(`
|
||||
(function_declaration name:(identifier) @fn-def)
|
||||
(call_expression function:(identifier) @fn-ref)
|
||||
`);
|
||||
const matches = query.exec(tree.rootNode);
|
||||
assert.deepEqual(
|
||||
|
|
@ -42,9 +43,9 @@ describe("Query", () => {
|
|||
captures: captures.map(({name, node}) => ({name, text: node.text}))
|
||||
})),
|
||||
[
|
||||
{pattern: 0, captures: [{name: 'the-name', text: 'one'}]},
|
||||
// {pattern: 0, captures: [{name: 'the-function', text: 'two'}]},
|
||||
{pattern: 0, captures: [{name: 'the-name', text: 'three'}]},
|
||||
{pattern: 0, captures: [{name: 'fn-def', text: 'one'}]},
|
||||
{pattern: 1, captures: [{name: 'fn-ref', text: 'two'}]},
|
||||
{pattern: 0, captures: [{name: 'fn-def', text: 'three'}]},
|
||||
]
|
||||
);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue