Fix handling of extra nodes in query analysis

Fixes #967
This commit is contained in:
Max Brunsfeld 2021-03-06 14:35:41 -08:00
parent d037c4914d
commit f18c36ca62
2 changed files with 52 additions and 3 deletions

View file

@ -642,6 +642,49 @@ fn test_query_matches_capturing_error_nodes() {
});
}
#[test]
fn test_query_matches_with_extra_children() {
allocations::record(|| {
let language = get_language("ruby");
let query = Query::new(
language,
"
(program(comment) @top_level_comment)
(argument_list (heredoc_body) @heredoc_in_args)
",
)
.unwrap();
assert_query_matches(
language,
&query,
"
# top-level
puts(
# not-top-level
<<-IN_ARGS, bar.baz
HELLO
IN_ARGS
)
puts <<-NOT_IN_ARGS
NO
NOT_IN_ARGS
",
&[
(0, vec![("top_level_comment", "# top-level")]),
(
1,
vec![(
"heredoc_in_args",
"\n HELLO\n IN_ARGS",
)],
),
],
);
});
}
#[test]
fn test_query_matches_with_named_wildcard() {
allocations::record(|| {