From 41d3e16eac821845ca95f75af5ca00a17d22e4f8 Mon Sep 17 00:00:00 2001 From: Will Lillis Date: Sun, 28 Jun 2026 01:15:02 -0400 Subject: [PATCH] test(query): regression test for anchored siblings inside a parent --- crates/cli/src/tests/query_test.rs | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/crates/cli/src/tests/query_test.rs b/crates/cli/src/tests/query_test.rs index 3818f31c5..2af35e4c9 100644 --- a/crates/cli/src/tests/query_test.rs +++ b/crates/cli/src/tests/query_test.rs @@ -1692,6 +1692,49 @@ fn test_matches_with_anchor_sibling_with_quantifier_captured_inside_parent() { }); } +#[test] +fn test_matches_anchored_quantified_sibling_inside_parent() { + allocations::record(|| { + let language = get_language("c"); + let query = Query::new( + &language, + "(translation_unit (comment)* @comment . (declaration) @decl)", + ) + .unwrap(); + assert_query_matches( + &language, + &query, + " +void foo() {} + +// this one has +// two comments +extern int baz; + +// this one has a comment +extern int bar; +", + &[ + ( + 0, + vec![ + ("comment", "// this one has"), + ("comment", "// two comments"), + ("decl", "extern int baz;"), + ], + ), + ( + 0, + vec![ + ("comment", "// this one has a comment"), + ("decl", "extern int bar;"), + ], + ), + ], + ); + }); +} + #[test] fn test_query_matches_with_trailing_optional_nodes() { allocations::record(|| {