mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-09 20:12:57 +00:00
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.
This commit is contained in:
1 parent
e21a078b5a
commit
2d10f23bf4
1 file changed
+26
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user