From 374920ad0f8ea4a9f1a2f71b6b656b0f470a4ed3 Mon Sep 17 00:00:00 2001 From: Elijah Potter Date: Wed, 22 Jan 2025 15:47:41 -0700 Subject: [PATCH] test(core): add and fix tests from #470 --- harper-core/src/linting/lets_confusion/mod.rs | 10 ++++++++++ .../linting/lets_confusion/no_contraction_with_verb.rs | 7 +++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/harper-core/src/linting/lets_confusion/mod.rs b/harper-core/src/linting/lets_confusion/mod.rs index d0e3f0fa..113b3b33 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 7d7925f8..a919aa70 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),