From 9f34c5ad61da9e338ec31e10cfad7187085fc661 Mon Sep 17 00:00:00 2001 From: Naxvog Date: Wed, 14 Oct 2026 21:27:17 +0200 Subject: [PATCH] Hyphenation: exact German pattern count, a parser test for skipped commands Co-Authored-By: Claude Opus 5.5 --- crates/proof/src/hyphen.rs | 2 +- crates/proof/src/patterns.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/proof/src/hyphen.rs b/crates/proof/src/hyphen.rs index 1db67eb02..00297331e 100644 --- a/crates/proof/src/hyphen.rs +++ b/crates/proof/src/hyphen.rs @@ -861,7 +861,7 @@ mod tests { #[test] fn german_patterns_load() { let p = Patterns::de(); - assert!(p.len() >= 36_709, "{}", p.len()); + assert_eq!(p.len(), 36_709); // The file has no exception words, and its `\message{…}` line adds none. assert_eq!(p.exception_count(), 0); } diff --git a/crates/proof/src/patterns.rs b/crates/proof/src/patterns.rs index 08d54a947..a91235e48 100644 --- a/crates/proof/src/patterns.rs +++ b/crates/proof/src/patterns.rs @@ -142,6 +142,7 @@ impl Patterns { block = match name { "hyphenation" => Block::Exceptions, "patterns" => Block::Patterns, + // shortcut: the argument ends at the first `}`, so nested braces would leak; no bundled file has them. _ if cmd.contains('{') => Block::Skip, _ => Block::Patterns, }; @@ -345,6 +346,12 @@ mod tests { assert!(p.to_tex().contains(&".ab4cdefghijklm5n".to_string())); } + #[test] + fn other_commands_arguments_are_skipped() { + let p = Patterns::parse("\\message{Some Patterns `x-y' 2024-02-28}\n\\patterns{%\na1b\n}\n\\endinput\n"); + assert_eq!((p.len(), p.exception_count()), (1, 0)); + } + #[test] fn apply_tolerates_short_value_buffers() { let p = Patterns::parse("a1b");