harper_core/linting/hop_hope/
mod.rs1use super::merge_linters::merge_linters;
2
3mod to_hop;
4mod to_hope;
5use to_hop::ToHop;
6use to_hope::ToHope;
7
8merge_linters!(HopHope => ToHop, ToHope => "Handles common errors involving `hop` and `hope`. Ensures `hop` is used correctly in phrases like `hop on a bus` while correcting mistaken uses of `hope` in contexts where `hop` is expected.");
9
10#[cfg(test)]
11mod tests {
12 use super::HopHope;
13 use crate::linting::tests::assert_suggestion_result;
14
15 #[test]
16 fn corrects_hop_to_hope() {
17 assert_suggestion_result(
18 "I hop we can clarify this soon.",
19 HopHope::default(),
20 "I hope we can clarify this soon.",
21 );
22 }
23
24 #[test]
25 fn does_not_correct_unrelated_use() {
26 assert_suggestion_result(
27 "I hop on one foot for fun.",
28 HopHope::default(),
29 "I hop on one foot for fun.",
30 );
31 }
32
33 #[test]
34 fn corrects_mixed_case_hop() {
35 assert_suggestion_result(
36 "I HoP we can find a solution.",
37 HopHope::default(),
38 "I HoPE we can find a solution.",
39 );
40 }
41
42 #[test]
43 fn corrects_hoping_on_call() {
44 assert_suggestion_result(
45 "I was hoping on a call to discuss this.",
46 HopHope::default(),
47 "I was hopping on a call to discuss this.",
48 );
49 }
50
51 #[test]
52 fn corrects_hoped_on_plane() {
53 assert_suggestion_result(
54 "She hoped on an airplane to visit family.",
55 HopHope::default(),
56 "She hopped on an airplane to visit family.",
57 );
58 }
59
60 #[test]
61 fn corrects_hope_on_bus() {
62 assert_suggestion_result(
63 "They hope on a bus every morning.",
64 HopHope::default(),
65 "They hop on a bus every morning.",
66 );
67 }
68
69 #[test]
70 fn does_not_correct_unrelated_context() {
71 assert_suggestion_result(
72 "I hope everything goes well with your project.",
73 HopHope::default(),
74 "I hope everything goes well with your project.",
75 );
76 }
77
78 #[test]
79 fn corrects_mixed_case() {
80 assert_suggestion_result(
81 "She HoPeD on a train to get home.",
82 HopHope::default(),
83 "She HoPpED on a train to get home.",
84 );
85 }
86}