Cotton code
29 lines · 1.0 KB · RustRaw
//! Regex compilation and ASCII boundary behavior; product vocabulary stays editable data.use super::{retired_regex, RETIRED_TERMS_STRICT};#[test]fn every_pattern_compiles() {    for term in RETIRED_TERMS_STRICT.iter() {        // `retired_regex` panics with the pattern named if it does not.        let _ = retired_regex(term.pattern);    }}/// RULE: Retired-word regexes fold ASCII case and use ASCII word boundaries, so the same declared pattern behaves like the JavaScript reader beside accented letters.#[test]fn regex_flags_match_ascii_javascript_semantics() {    let pattern = retired_regex(r"\bneedle\b");    for text in ["needle", "NEEDLE", "éneedle", "needleé"] {        assert!(pattern.is_match(text), "{text}");    }    for text in ["needles", "needlework", "hay"] {        assert!(!pattern.is_match(text), "{text}");    }    let folding = retired_regex(r"\bkeys\b");    assert!(folding.is_match("KEYS"));    for text in ["Keys", "keyſ"] {        assert!(!folding.is_match(text), "{text} must not fold as ASCII");    }}