From 2d10f23bf4d600835ea499d963193fcede9c6908 Mon Sep 17 00:00:00 2001 From: Skaywalker <115165402+Skaywalker@users.noreply.github.com> Date: Wed, 21 Oct 2026 20:47:25 +0200 Subject: [PATCH] proof: test that unsupported directives are refused and morphology-only flags load COMPOUNDFIRST and COMPOUNDLAST, the older names of COMPOUNDBEGIN and COMPOUNDEND, are refused like them until compounding is supported. --- crates/proof/src/affix.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crates/proof/src/affix.rs b/crates/proof/src/affix.rs index 4ce915af..77364511 100644 --- a/crates/proof/src/affix.rs +++ b/crates/proof/src/affix.rs @@ -42,7 +42,9 @@ const UNSUPPORTED: &[&str] = &[ "COMPLEXPREFIXES", "COMPOUNDBEGIN", "COMPOUNDEND", + "COMPOUNDFIRST", "COMPOUNDFLAG", + "COMPOUNDLAST", "COMPOUNDMIDDLE", "COMPOUNDMIN", "COMPOUNDPERMITFLAG", @@ -1594,6 +1596,30 @@ pub(crate) mod tests { assert!(back.check("km") && !back.check("Km")); } + #[test] + fn morphology_only_flags_leave_words_correct() { + // `SUBSTANDARD` and `LEMMA_PRESENT` only steer morphological generation: the stems and + // rules they mark are still correct. + let aff = "SET UTF-8\nSUBSTANDARD x\nLEMMA_PRESENT l\nSFX a Y 2\nSFX a 0 y .\nSFX a 0 em/x .\n"; + let d = AffixDict::from_hunspell(aff, "2\nkot/a\npies/axl\n", &[]).unwrap(); + assert!(d.check("kot") && d.check("koty") && d.check("kotem")); + assert!(d.check("pies") && d.check("piesy") && d.check("piesem")); + } + + #[test] + fn unsupported_directives_are_refused_and_the_rest_load() { + // A dictionary that needs a directive outside this engine fails to load rather than + // accepting the wrong words. + for dir in UNSUPPORTED { + assert!(AffixDict::from_hunspell(&format!("SET UTF-8\n{dir} X\n"), DIC, &[]).is_err(), "{dir} should be refused"); + } + // The directives this engine reads, with no other change to the dictionary. + for line in ["AF 1\nAF ab", "AM 1\nAM po:noun", "ICONV 1\nICONV fi fi", "IGNORE ()", "KEEPCASE k", "SUBSTANDARD x", "LEMMA_PRESENT l"] { + let d = AffixDict::from_hunspell(&format!("{AFF}{line}\n"), DIC, &[]).unwrap_or_else(|e| panic!("{line}: {e}")); + assert!(d.check("koty") && d.check("niekoty") && !d.check("kotx"), "{line}"); + } + } + #[test] fn fields_split_on_spaces_and_tabs_only() { // A flag byte read as U+00A0 (no-break space) or U+0085 is a flag, not a separator.