use super::regex;
#[test]
fn intersection_matches_consonants_of_a_to_z() {
let re = regex("[a-z&&[^aeiou]]");
assert!(re.is_match("b"));
assert!(!re.is_match("a"));
}
#[test]
fn difference_matches_consonants_of_a_to_z() {
let re = regex("[a-z--[aeiou]]");
assert!(re.is_match("b"));
assert!(!re.is_match("a"));
}
#[test]
fn symmetric_difference_matches_code_points_in_exactly_one_side() {
let re = regex("[a-g~~[d-z]]");
assert!(re.is_match("b")); assert!(!re.is_match("d")); assert!(re.is_match("z")); }
#[test]
fn operators_are_left_associative_and_chain() {
let re = regex("[a-z&&[^aeiou]--[xyz]]");
assert!(re.is_match("b"));
assert!(!re.is_match("a")); assert!(!re.is_match("x")); }
#[test]
fn operand_may_be_a_bare_run_of_members_on_either_side() {
let re = regex("[a-z&&aeiou]");
assert!(re.is_match("a"));
assert!(!re.is_match("b"));
let re = regex("[aeiou--a]");
assert!(re.is_match("e"));
assert!(!re.is_match("a"));
}
#[test]
fn leading_negation_applies_to_the_whole_computed_set_last() {
let re = regex("[^a-z&&[^aeiou]]");
assert!(!re.is_match("b")); assert!(re.is_match("a")); assert!(re.is_match("9")); }
#[test]
fn single_ampersand_is_still_a_literal_member() {
let re = regex("[a&b]");
assert!(re.is_match("a"));
assert!(re.is_match("&"));
assert!(re.is_match("b"));
assert!(!re.is_match("c"));
}
#[test]
fn single_hyphen_is_still_a_range_operator() {
let re = regex("[a-z]");
assert!(re.is_match("m"));
assert!(!re.is_match("A"));
}
#[test]
fn single_hyphen_at_class_edges_is_still_a_literal() {
let leading = regex("[-a]");
assert!(leading.is_match("-"));
assert!(leading.is_match("a"));
assert!(!leading.is_match("b"));
let trailing = regex("[a-]");
assert!(trailing.is_match("-"));
assert!(trailing.is_match("a"));
assert!(!trailing.is_match("b"));
}
#[test]
fn single_tilde_is_still_a_literal_member() {
let re = regex("[a~b]");
assert!(re.is_match("a"));
assert!(re.is_match("~"));
assert!(re.is_match("b"));
assert!(!re.is_match("c"));
}
#[test]
fn nested_class_union_still_works() {
let re = regex("[[ab]|[cd]]");
assert!(re.is_match("a"));
assert!(re.is_match("|"));
assert!(re.is_match("c"));
}
#[test]
fn nested_class_composition_still_works() {
let re = regex("[a[b-c]]");
assert!(re.is_match("a"));
assert!(re.is_match("b"));
assert!(re.is_match("c"));
assert!(!re.is_match("d"));
}
#[test]
fn set_op_not_confused_with_posix_class_syntax() {
let re = regex("[[:alpha:]]");
assert!(re.is_match("a"));
assert!(!re.is_match("9"));
let re = regex("[a-z&&[^aeiou]]");
assert!(re.is_match("b"));
assert!(!re.is_match("a"));
}