Skip to content

Commit

Permalink
extra tests for optional expression tags
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtau authored and Tomas Tauber committed Mar 1, 2024
1 parent 3f57932 commit 1e36973
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions derive/tests/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,18 @@ fn test_opt_tag() {
let pairs = successful_parse.unwrap();
assert!(pairs.find_first_tagged("prefix").is_some());
assert!(pairs.find_first_tagged("suffix").is_none());

// Test with no STAR or DOT
let parse_no_components = TestOptParser::parse(Rule::expr, "");
assert!(parse_no_components.is_ok());
let pairs_no_components = parse_no_components.unwrap();
assert!(pairs_no_components.find_first_tagged("prefix").is_none());
assert!(pairs_no_components.find_first_tagged("suffix").is_none());

// Test with only DOT
let parse_only_dot = TestOptParser::parse(Rule::expr, ".");
assert!(parse_only_dot.is_ok());
let pairs_only_dot = parse_only_dot.unwrap();
assert!(pairs_only_dot.find_first_tagged("prefix").is_none());
assert!(pairs_only_dot.find_first_tagged("suffix").is_some());
}

0 comments on commit 1e36973

Please sign in to comment.