Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
test(core): added more cases for Oxford commas and noun phrase detection
Elijah Potterd516897711fc
diff --git a/harper-core/dictionary.dict b/harper-core/dictionary.dictindex ead6ece24..89409a695 100644--- a/harper-core/dictionary.dict+++ b/harper-core/dictionary.dict@@ -15268,7 +15268,7 @@ bureaucratization/1Mbureaucratize/4GDSburg/1MRZSburgeon/14DSG-burger/1M+burger/1MSburgh/1MRZburgher/1Mburghs/1diff --git a/harper-core/src/linting/oxford_comma.rs b/harper-core/src/linting/oxford_comma.rsindex 01fcc2d82..51dcf683d 100644--- a/harper-core/src/linting/oxford_comma.rs+++ b/harper-core/src/linting/oxford_comma.rs@@ -98,11 +98,42 @@ mod tests {#[test]fn people() {- // Nancy, Steve and Carl are goingassert_suggestion_result("Nancy, Steve and Carl are going to the coffee shop.",OxfordComma::default(),"Nancy, Steve, and Carl are going to the coffee shop.",);}++ #[test]+ fn places() {+ assert_suggestion_result(+ "I've always wanted to visit Paris, Tokyo and Rome.",+ OxfordComma::default(),+ "I've always wanted to visit Paris, Tokyo, and Rome.",+ );+ }++ #[test]+ fn foods() {+ assert_suggestion_result(+ "My favorite foods are pizza, sushi, tacos and burgers.",+ OxfordComma::default(),+ "My favorite foods are pizza, sushi, tacos, and burgers.",+ );+ }++ #[test]+ fn allows_clean_music() {+ assert_lint_count(+ "I enjoy listening to pop music, rock, hip-hop, electronic dance, and classical music.",+ OxfordComma::default(),+ 0,+ );+ }++ #[test]+ fn allows_clean_nations() {+ assert_lint_count("The team consists of players from different countries: France, Germany, Italy, and Spain.", OxfordComma::default(), 0);+ }}diff --git a/harper-core/src/patterns/noun_phrase.rs b/harper-core/src/patterns/noun_phrase.rsindex 31d18bc04..66d25e4f2 100644--- a/harper-core/src/patterns/noun_phrase.rs+++ b/harper-core/src/patterns/noun_phrase.rs@@ -75,4 +75,25 @@ mod tests {let doc = Document::new_markdown_curated("a banana");assert!(NounPhrase.matches(doc.get_tokens(), doc.get_source()) != 0);}++ #[test]+ fn food() {+ let doc = Document::new_markdown_curated(+ "My favorite foods are pizza, sushi, tacos and burgers.",+ );+ let matches = NounPhrase.find_all_matches_in_doc(&doc);++ dbg!(&matches);++ assert_eq!(+ matches,+ vec![+ Span::new(2, 5),+ Span::new(8, 9),+ Span::new(11, 12),+ Span::new(14, 15),+ Span::new(18, 19)+ ]+ )+ }}