Skip to content

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

test(core): add and fix tests from #470

Elijah Potter374920ad0f8e
diff --git a/harper-core/src/linting/lets_confusion/mod.rs b/harper-core/src/linting/lets_confusion/mod.rs
index d0e3f0fa0..113b3b338 100644
--- a/harper-core/src/linting/lets_confusion/mod.rs
+++ b/harper-core/src/linting/lets_confusion/mod.rs
@@ -27,4 +27,14 @@ mod tests {
fn from_harper_docs() {
assert_suggestion_result("Often the longest and the shortest words are the most helpful, so lets push them first.", LetsConfusion::default(), "Often the longest and the shortest words are the most helpful, so let's push them first.");
}
+
+ #[test]
+ fn issue_470_missing_apostrophe() {
+ assert_suggestion_result("lets play", LetsConfusion::default(), "let's play");
+ }
+
+ #[test]
+ fn issue_470_missing_subject() {
+ assert_suggestion_result("let play", LetsConfusion::default(), "let's play");
+ }
}
diff --git a/harper-core/src/linting/lets_confusion/no_contraction_with_verb.rs b/harper-core/src/linting/lets_confusion/no_contraction_with_verb.rs
index 7d7925f8e..a919aa707 100644
--- a/harper-core/src/linting/lets_confusion/no_contraction_with_verb.rs
+++ b/harper-core/src/linting/lets_confusion/no_contraction_with_verb.rs
@@ -1,6 +1,6 @@
use crate::{
linting::{Lint, LintKind, Suggestion},
- patterns::{Pattern, SequencePattern},
+ patterns::{Pattern, SequencePattern, WordSet},
Token,
};
@@ -12,7 +12,10 @@ pub struct NoContractionWithVerb {
impl Default for NoContractionWithVerb {
fn default() -> Self {
- let pattern = SequencePattern::aco("lets").then_whitespace().then_verb();
+ let pattern = SequencePattern::default()
+ .then_word_set(WordSet::all(&["lets", "let"]))
+ .then_whitespace()
+ .then_verb();
Self {
pattern: Box::new(pattern),