Skip to content

Offline, privacy-first grammar checker. Fast, open-source, Rust-powered

refactor: tests for spell/mod.rs and and linting/spell_check.rs were arbitrary mixed (#2809)

Andrew Dunbar3a4ca553f6f1
diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rs
index e2041c3bc..d78d264d7 100644
--- a/harper-core/src/linting/mod.rs
+++ b/harper-core/src/linting/mod.rs
@@ -253,7 +253,6 @@ pub use lint_group::{LintGroup, LintGroupConfig};
pub use lint_kind::LintKind;
pub use map_phrase_linter::MapPhraseLinter;
pub use map_phrase_set_linter::MapPhraseSetLinter;
-pub use spell_check::SpellCheck;
pub use suggestion::{Suggestion, SuggestionCollectionExt};
use crate::{Document, LSend, render_markdown};
diff --git a/harper-core/src/linting/spell_check.rs b/harper-core/src/linting/spell_check.rs
index baae49248..2b35e52ab 100644
--- a/harper-core/src/linting/spell_check.rs
+++ b/harper-core/src/linting/spell_check.rs
@@ -531,4 +531,455 @@ mod tests {
&["MacOS"],
);
}
+
+ // Tests that were previously in `spell/mod.rs`
+
+ // Tests for dialect-specific misspelling patterns
+
+ // is_ou_misspelling
+ #[test]
+ fn suggest_color_for_colour_lowercase() {
+ assert_suggestion_result(
+ "colour",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "color",
+ );
+ }
+
+ #[test]
+ fn suggest_colour_for_color_lowercase() {
+ assert_suggestion_result(
+ "color",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "colour",
+ );
+ }
+
+ // titlecase
+ #[test]
+ fn suggest_color_for_colour_titlecase() {
+ assert_suggestion_result(
+ "Colour",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "Color",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_colour_for_color_titlecase() {
+ assert_suggestion_result(
+ "Color",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "Colour",
+ );
+ }
+
+ // all-caps
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_color_for_colour_all_caps() {
+ assert_suggestion_result(
+ "COLOUR",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "COLOR",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_colour_for_color_all_caps() {
+ assert_suggestion_result(
+ "COLOR",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "COLOUR",
+ );
+ }
+
+ // is_cksz_misspelling
+
+ // s/z as in realise/realize
+ #[test]
+ #[ignore = "both spellings are acceptable in UK, AU, and IN despite popular opinion"]
+ fn suggest_realise_for_realize() {
+ assert_suggestion_result(
+ "realize",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "realise",
+ );
+ }
+
+ #[test]
+ fn suggest_realize_for_realise() {
+ assert_suggestion_result(
+ "realise",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "realize",
+ );
+ }
+
+ #[test]
+ #[ignore = "both spellings are acceptable in UK, AU, and IN despite popular opinion"]
+ fn suggest_realise_for_realize_titlecase() {
+ assert_suggestion_result(
+ "Realize",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "Realise",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_realize_for_realise_titlecase() {
+ assert_suggestion_result(
+ "Realise",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "Realize",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_realise_for_realize_all_caps() {
+ assert_suggestion_result(
+ "REALIZE",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "REALISE",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_realize_for_realise_all_caps() {
+ assert_suggestion_result(
+ "REALISE",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "REALIZE",
+ );
+ }
+
+ // s/c as in defense/defence
+ #[test]
+ fn suggest_defence_for_defense() {
+ assert_suggestion_result(
+ "defense",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "defence",
+ );
+ }
+
+ #[test]
+ fn suggest_defense_for_defence() {
+ assert_suggestion_result(
+ "defence",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "defense",
+ );
+ }
+
+ #[test]
+ fn suggest_defense_for_defence_titlecase() {
+ assert_suggestion_result(
+ "Defense",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "Defence",
+ );
+ }
+
+ #[test]
+ fn suggest_defence_for_defense_titlecase() {
+ assert_suggestion_result(
+ "Defence",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "Defense",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_defense_for_defence_all_caps() {
+ assert_suggestion_result(
+ "DEFENSE",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "DEFENCE",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_defence_for_defense_all_caps() {
+ assert_suggestion_result(
+ "DEFENCE",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "DEFENSE",
+ );
+ }
+
+ // k/c as in skeptic/sceptic
+ #[test]
+ fn suggest_sceptic_for_skeptic() {
+ assert_suggestion_result(
+ "skeptic",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "sceptic",
+ );
+ }
+
+ #[test]
+ fn suggest_skeptic_for_sceptic() {
+ assert_suggestion_result(
+ "sceptic",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "skeptic",
+ );
+ }
+
+ #[test]
+ fn suggest_sceptic_for_skeptic_titlecase() {
+ assert_suggestion_result(
+ "Skeptic",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "Sceptic",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_skeptic_for_sceptic_titlecase() {
+ assert_suggestion_result(
+ "Sceptic",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "Skeptic",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_skeptic_for_sceptic_all_caps() {
+ assert_suggestion_result(
+ "SKEPTIC",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "SCEPTIC",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_sceptic_for_skeptic_all_caps() {
+ assert_suggestion_result(
+ "SCEPTIC",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "SKEPTIC",
+ );
+ }
+
+ // is_er_misspelling
+ // as in meter/metre
+ #[test]
+ fn suggest_centimeter_for_centimetre() {
+ assert_suggestion_result(
+ "centimetre",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "centimeter",
+ );
+ }
+
+ #[test]
+ fn suggest_centimetre_for_centimeter() {
+ assert_suggestion_result(
+ "centimeter",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "centimetre",
+ );
+ }
+
+ #[test]
+ fn suggest_centimeter_for_centimetre_titlecase() {
+ assert_suggestion_result(
+ "Centimetre",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "Centimeter",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_centimetre_for_centimeter_titlecase() {
+ assert_suggestion_result(
+ "Centimeter",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "Centimetre",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_centimeter_for_centimetre_all_caps() {
+ assert_suggestion_result(
+ "CENTIMETRE",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "CENTIMETER",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_centimetre_for_centimeter_all_caps() {
+ assert_suggestion_result(
+ "CENTIMETER",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "CENTIMETRE",
+ );
+ }
+
+ // is_ll_misspelling
+ // as in traveller/traveler
+ #[test]
+ fn suggest_traveler_for_traveller() {
+ assert_suggestion_result(
+ "traveller",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "traveler",
+ );
+ }
+
+ #[test]
+ fn suggest_traveller_for_traveler() {
+ assert_suggestion_result(
+ "traveler",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "traveller",
+ );
+ }
+
+ #[test]
+ fn suggest_traveler_for_traveller_titlecase() {
+ assert_suggestion_result(
+ "Traveller",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "Traveler",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_traveller_for_traveler_titlecase() {
+ assert_suggestion_result(
+ "Traveler",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "Traveller",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_traveler_for_traveller_all_caps() {
+ assert_suggestion_result(
+ "TRAVELLER",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "TRAVELER",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_traveller_for_traveler_all_caps() {
+ assert_suggestion_result(
+ "TRAVELER",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "TRAVELLER",
+ );
+ }
+
+ // is_ay_ey_misspelling
+ // as in gray/grey
+
+ #[test]
+ fn suggest_grey_for_gray_in_non_american() {
+ assert_suggestion_result(
+ "I've got a gray cat.",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "I've got a grey cat.",
+ );
+ }
+
+ #[test]
+ fn suggest_gray_for_grey_in_american() {
+ assert_suggestion_result(
+ "It's a greyscale photo.",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "It's a grayscale photo.",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_grey_for_gray_in_non_american_titlecase() {
+ assert_suggestion_result(
+ "I've Got a Gray Cat.",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "I've Got a Grey Cat.",
+ );
+ }
+
+ #[test]
+ fn suggest_gray_for_grey_in_american_titlecase() {
+ assert_suggestion_result(
+ "It's a Greyscale Photo.",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "It's a Grayscale Photo.",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_grey_for_gray_in_non_american_all_caps() {
+ assert_suggestion_result(
+ "GRAY",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "GREY",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn suggest_gray_for_grey_in_american_all_caps() {
+ assert_suggestion_result(
+ "GREY",
+ SpellCheck::new(FstDictionary::curated(), Dialect::American),
+ "GRAY",
+ );
+ }
+
+ // Tests for non-dialectal misspelling patterns
+
+ // is_ei_ie_misspelling
+ #[test]
+ fn fix_cheif_and_recieved() {
+ assert_top3_suggestion_result(
+ "The cheif recieved a letter.",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "The chief received a letter.",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn fix_cheif_and_recieved_titlecase() {
+ assert_top3_suggestion_result(
+ "The Cheif Recieved a Letter.",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "The Chief Received a Letter.",
+ );
+ }
+
+ #[test]
+ #[ignore = "known failure due to bug"]
+ fn fix_cheif_and_recieved_all_caps() {
+ assert_top3_suggestion_result(
+ "THE CHEIF RECIEVED A LETTER.",
+ SpellCheck::new(FstDictionary::curated(), Dialect::British),
+ "THE CHEIF RECEIVED A LETTER.",
+ );
+ }
}
diff --git a/harper-core/src/spell/mod.rs b/harper-core/src/spell/mod.rs
index 6eae01eb9..cf4c1db14 100644
--- a/harper-core/src/spell/mod.rs
+++ b/harper-core/src/spell/mod.rs
@@ -399,13 +399,7 @@ pub fn suggest_correct_spelling_str(
mod tests {
use itertools::Itertools;
- use crate::{
- CharStringExt, Dialect,
- linting::{
- SpellCheck,
- tests::{assert_suggestion_result, assert_top3_suggestion_result},
- },
- };
+ use crate::CharStringExt;
use super::{FstDictionary, suggest_correct_spelling_str};
@@ -556,453 +550,4 @@ mod tests {
fn conciousness_correction() {
assert_suggests_correction("conciousness", "consciousness");
}
-
- // Tests for dialect-specific misspelling patterns
-
- // is_ou_misspelling
- #[test]
- fn suggest_color_for_colour_lowercase() {
- assert_suggestion_result(
- "colour",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "color",
- );
- }
-
- #[test]
- fn suggest_colour_for_color_lowercase() {
- assert_suggestion_result(
- "color",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "colour",
- );
- }
-
- // titlecase
- #[test]
- fn suggest_color_for_colour_titlecase() {
- assert_suggestion_result(
- "Colour",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "Color",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_colour_for_color_titlecase() {
- assert_suggestion_result(
- "Color",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "Colour",
- );
- }
-
- // all-caps
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_color_for_colour_all_caps() {
- assert_suggestion_result(
- "COLOUR",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "COLOR",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_colour_for_color_all_caps() {
- assert_suggestion_result(
- "COLOR",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "COLOUR",
- );
- }
-
- // is_cksz_misspelling
-
- // s/z as in realise/realize
- #[test]
- #[ignore = "both spellings are acceptable in UK, AU, and IN despite popular opinion"]
- fn suggest_realise_for_realize() {
- assert_suggestion_result(
- "realize",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "realise",
- );
- }
-
- #[test]
- fn suggest_realize_for_realise() {
- assert_suggestion_result(
- "realise",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "realize",
- );
- }
-
- #[test]
- #[ignore = "both spellings are acceptable in UK, AU, and IN despite popular opinion"]
- fn suggest_realise_for_realize_titlecase() {
- assert_suggestion_result(
- "Realize",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "Realise",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_realize_for_realise_titlecase() {
- assert_suggestion_result(
- "Realise",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "Realize",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_realise_for_realize_all_caps() {
- assert_suggestion_result(
- "REALIZE",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "REALISE",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_realize_for_realise_all_caps() {
- assert_suggestion_result(
- "REALISE",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "REALIZE",
- );
- }
-
- // s/c as in defense/defence
- #[test]
- fn suggest_defence_for_defense() {
- assert_suggestion_result(
- "defense",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "defence",
- );
- }
-
- #[test]
- fn suggest_defense_for_defence() {
- assert_suggestion_result(
- "defence",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "defense",
- );
- }
-
- #[test]
- fn suggest_defense_for_defence_titlecase() {
- assert_suggestion_result(
- "Defense",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "Defence",
- );
- }
-
- #[test]
- fn suggest_defence_for_defense_titlecase() {
- assert_suggestion_result(
- "Defence",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "Defense",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_defense_for_defence_all_caps() {
- assert_suggestion_result(
- "DEFENSE",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "DEFENCE",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_defence_for_defense_all_caps() {
- assert_suggestion_result(
- "DEFENCE",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "DEFENSE",
- );
- }
-
- // k/c as in skeptic/sceptic
- #[test]
- fn suggest_sceptic_for_skeptic() {
- assert_suggestion_result(
- "skeptic",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "sceptic",
- );
- }
-
- #[test]
- fn suggest_skeptic_for_sceptic() {
- assert_suggestion_result(
- "sceptic",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "skeptic",
- );
- }
-
- #[test]
- fn suggest_sceptic_for_skeptic_titlecase() {
- assert_suggestion_result(
- "Skeptic",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "Sceptic",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_skeptic_for_sceptic_titlecase() {
- assert_suggestion_result(
- "Sceptic",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "Skeptic",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_skeptic_for_sceptic_all_caps() {
- assert_suggestion_result(
- "SKEPTIC",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "SCEPTIC",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_sceptic_for_skeptic_all_caps() {
- assert_suggestion_result(
- "SCEPTIC",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "SKEPTIC",
- );
- }
-
- // is_er_misspelling
- // as in meter/metre
- #[test]
- fn suggest_centimeter_for_centimetre() {
- assert_suggestion_result(
- "centimetre",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "centimeter",
- );
- }
-
- #[test]
- fn suggest_centimetre_for_centimeter() {
- assert_suggestion_result(
- "centimeter",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "centimetre",
- );
- }
-
- #[test]
- fn suggest_centimeter_for_centimetre_titlecase() {
- assert_suggestion_result(
- "Centimetre",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "Centimeter",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_centimetre_for_centimeter_titlecase() {
- assert_suggestion_result(
- "Centimeter",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "Centimetre",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_centimeter_for_centimetre_all_caps() {
- assert_suggestion_result(
- "CENTIMETRE",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "CENTIMETER",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_centimetre_for_centimeter_all_caps() {
- assert_suggestion_result(
- "CENTIMETER",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "CENTIMETRE",
- );
- }
-
- // is_ll_misspelling
- // as in traveller/traveler
- #[test]
- fn suggest_traveler_for_traveller() {
- assert_suggestion_result(
- "traveller",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "traveler",
- );
- }
-
- #[test]
- fn suggest_traveller_for_traveler() {
- assert_suggestion_result(
- "traveler",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "traveller",
- );
- }
-
- #[test]
- fn suggest_traveler_for_traveller_titlecase() {
- assert_suggestion_result(
- "Traveller",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "Traveler",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_traveller_for_traveler_titlecase() {
- assert_suggestion_result(
- "Traveler",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "Traveller",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_traveler_for_traveller_all_caps() {
- assert_suggestion_result(
- "TRAVELLER",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "TRAVELER",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_traveller_for_traveler_all_caps() {
- assert_suggestion_result(
- "TRAVELER",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "TRAVELLER",
- );
- }
-
- // is_ay_ey_misspelling
- // as in gray/grey
-
- #[test]
- fn suggest_grey_for_gray_in_non_american() {
- assert_suggestion_result(
- "I've got a gray cat.",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "I've got a grey cat.",
- );
- }
-
- #[test]
- fn suggest_gray_for_grey_in_american() {
- assert_suggestion_result(
- "It's a greyscale photo.",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "It's a grayscale photo.",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_grey_for_gray_in_non_american_titlecase() {
- assert_suggestion_result(
- "I've Got a Gray Cat.",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "I've Got a Grey Cat.",
- );
- }
-
- #[test]
- fn suggest_gray_for_grey_in_american_titlecase() {
- assert_suggestion_result(
- "It's a Greyscale Photo.",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "It's a Grayscale Photo.",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_grey_for_gray_in_non_american_all_caps() {
- assert_suggestion_result(
- "GRAY",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "GREY",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn suggest_gray_for_grey_in_american_all_caps() {
- assert_suggestion_result(
- "GREY",
- SpellCheck::new(FstDictionary::curated(), Dialect::American),
- "GRAY",
- );
- }
-
- // Tests for non-dialectal misspelling patterns
-
- // is_ei_ie_misspelling
- #[test]
- fn fix_cheif_and_recieved() {
- assert_top3_suggestion_result(
- "The cheif recieved a letter.",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "The chief received a letter.",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn fix_cheif_and_recieved_titlecase() {
- assert_top3_suggestion_result(
- "The Cheif Recieved a Letter.",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "The Chief Received a Letter.",
- );
- }
-
- #[test]
- #[ignore = "known failure due to bug"]
- fn fix_cheif_and_recieved_all_caps() {
- assert_top3_suggestion_result(
- "THE CHEIF RECIEVED A LETTER.",
- SpellCheck::new(FstDictionary::curated(), Dialect::British),
- "THE CHEIF RECEIVED A LETTER.",
- );
- }
}