Handle set! predicate function in queries

This commit is contained in:
Max Brunsfeld 2019-09-18 17:35:47 -07:00
parent ff9a2c1f53
commit b15e90bd26
5 changed files with 140 additions and 25 deletions

View file

@ -632,6 +632,33 @@ fn test_query_captures_with_text_conditions() {
});
}
#[test]
fn test_query_captures_with_set_properties() {
allocations::record(|| {
let language = get_language("javascript");
let query = Query::new(
language,
r#"
((call_expression (identifier) @foo)
(set! name something)
(set! age 24))
(property_identifier) @bar"#,
)
.unwrap();
assert_eq!(
query.pattern_properties(0),
&[
("name".to_string(), "something".to_string()),
("age".to_string(), "24".to_string()),
]
);
assert_eq!(query.pattern_properties(1), &[])
});
}
#[test]
fn test_query_captures_with_duplicates() {
allocations::record(|| {