From 6ac6637726e8dbdd6be77c1aa5df53e12f6c12aa Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Wed, 11 Nov 2026 22:41:16 +0000 Subject: [PATCH] address review: make the suggestion length-cap test deterministic --- crates/engine/src/cmd/spelling.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/cmd/spelling.rs b/crates/engine/src/cmd/spelling.rs index 96c8b236a..8ff9ac94d 100644 --- a/crates/engine/src/cmd/spelling.rs +++ b/crates/engine/src/cmd/spelling.rs @@ -337,11 +337,12 @@ mod tests { /// fifty copies of it per character. #[test] fn very_long_words_get_no_suggestions() { - let d = Dictionary::en_us(); - let long = "a".repeat(MAX_SUGGEST_CHARS + 1); - let t = std::time::Instant::now(); - assert!(suggest(d, &long).is_empty()); - assert!(t.elapsed() < std::time::Duration::from_secs(1)); + // The dictionary holds the longest allowed word, so deleting one letter of the 41-letter + // input would be a hit if the length cap were not applied. + let d = Dictionary::from_entries(vec![("a".repeat(MAX_SUGGEST_CHARS), 0)]); + assert_eq!(suggest(&d, &"a".repeat(MAX_SUGGEST_CHARS)), Vec::::new()); + assert_eq!(suggest(&d, &"a".repeat(MAX_SUGGEST_CHARS - 1)), vec!["a".repeat(MAX_SUGGEST_CHARS)]); + assert!(suggest(&d, &"a".repeat(MAX_SUGGEST_CHARS + 1)).is_empty()); } #[test]