Cotton code
33 lines · 1.2 KB · RustRaw
//! The retired vocabulary the generator writes into Swift.use super::*;#[test]fn the_strict_list_is_built_by_index_into_the_plain_one() {    // The declaration spells strict as the plain list plus one. Emitting it as    // `plain[0], plain[1], …` means an edit that broke that relationship fails    // the generator rather than producing two Swift tables free to disagree in    // one entry.    let swift = render_retired_terms().expect("rendered");    assert!(swift.contains("plain[0],"));    assert!(swift.contains("public static let plain: [RetiredTerm]"));    assert!(swift.contains("public static let strict: [RetiredTerm]"));    assert_eq!(        swift.matches("    plain[").count(),        RETIRED_TERMS.len(),        "the shared prefix is the whole plain list"    );}#[test]fn every_pattern_travels_as_a_raw_literal_with_its_own_backslashes() {    let swift = render_retired_terms().expect("rendered");    for term in RETIRED_TERMS {        assert!(            swift.contains(&format!("pattern: #\"{}\"#", term.pattern)),            "{} did not travel as a raw literal",            term.slug        );        assert!(swift.contains(&format!("slug: \"{}\"", term.slug)));    }}