Skip to content

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

test(core): track caller in asserts

Elijah Potterba91a5194306
diff --git a/harper-core/src/linting/mod.rs b/harper-core/src/linting/mod.rs
index 5a3728412..bc874164b 100644
--- a/harper-core/src/linting/mod.rs
+++ b/harper-core/src/linting/mod.rs
@@ -146,6 +146,7 @@ mod tests {
use super::Linter;
use crate::Document;
+ #[track_caller]
pub fn assert_lint_count(text: &str, mut linter: impl Linter, count: usize) {
let test = Document::new_markdown_default_curated(text);
let lints = linter.lint(&test);
@@ -155,6 +156,7 @@ mod tests {
/// Assert the total number of suggestions produced by a [`Linter`], spread across all produced
/// [`Lint`]s.
+ #[track_caller]
pub fn assert_suggestion_count(text: &str, mut linter: impl Linter, count: usize) {
let test = Document::new_markdown_default_curated(text);
let lints = linter.lint(&test);
@@ -166,6 +168,7 @@ mod tests {
/// Runs a provided linter on text, applies the first suggestion from each
/// lint and asserts whether the result is equal to a given value.
+ #[track_caller]
pub fn assert_suggestion_result(text: &str, mut linter: impl Linter, expected_result: &str) {
let test = Document::new_markdown_default_curated(text);
let lints = linter.lint(&test);
@@ -189,6 +192,7 @@ mod tests {
/// Runs a provided linter on text, applies the second suggestion from each
/// lint and asserts whether the result is equal to a given value.
+ #[track_caller]
pub fn assert_second_suggestion_result(
text: &str,
mut linter: impl Linter,
diff --git a/harper-core/src/spell/mod.rs b/harper-core/src/spell/mod.rs
index e97354ae7..01bf27794 100644
--- a/harper-core/src/spell/mod.rs
+++ b/harper-core/src/spell/mod.rs
@@ -182,6 +182,7 @@ mod tests {
/// Assert that the default suggestion settings result in a specific word
/// being in the top three results for a given misspelling.
+ #[track_caller]
fn assert_suggests_correction(misspelled_word: &str, correct: &str) {
let results = suggest_correct_spelling_str(
misspelled_word,