Skip to content

Commit

Permalink
feat: add utils defined vars
Browse files Browse the repository at this point in the history
  • Loading branch information
HerringtonDarkholme committed Apr 24, 2024
1 parent cbc6534 commit 59001eb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions crates/config/src/rule_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,4 +496,19 @@ utils:
let matcher = ser_rule.get_matcher(env).expect("should parse");
assert_eq!(matcher.defined_vars(), ["B"].into_iter().collect());
}

#[test]
fn test_defined_vars_cyclic() {
let env = DeserializeEnv::new(TypeScript::Tsx);
let ser_rule: SerializableRuleCore = from_str(
r"
rule: { matches: test1 }
utils:
test1: { pattern: $B, inside: {matches: test2} }
test2: { pattern: $A, has: {matches: test1} }",
)
.expect("should deser");
let matcher = ser_rule.get_matcher(env).expect("should parse");
assert_eq!(matcher.defined_vars(), ["A", "B"].into_iter().collect());
}
}

0 comments on commit 59001eb

Please sign in to comment.