on master help sign in
Fix Clippy lints in tests (#1563)
f064894Omnikar
helix-core/src/auto_pairs.rs+2−2
@@ -322,7 +322,7 @@ mod test {
322 use super::*;
322 use super::*;
323 use smallvec::smallvec;
323 use smallvec::smallvec;
324
324
325− const LINE_END: &'static str = crate::DEFAULT_LINE_ENDING.as_str();
325+ const LINE_END: &str = crate::DEFAULT_LINE_ENDING.as_str();
326
326
327 fn differing_pairs() -> impl Iterator<Item = &'static (char, char)> {
327 fn differing_pairs() -> impl Iterator<Item = &'static (char, char)> {
328 PAIRS.iter().filter(|(open, close)| open != close)
328 PAIRS.iter().filter(|(open, close)| open != close)
@@ -339,7 +339,7 @@ mod test {
339 expected_doc: &Rope,
339 expected_doc: &Rope,
340 expected_sel: &Selection,
340 expected_sel: &Selection,
341 ) {
341 ) {
342− let trans = hook(&in_doc, &in_sel, ch).unwrap();
342+ let trans = hook(in_doc, in_sel, ch).unwrap();
343 let mut actual_doc = in_doc.clone();
343 let mut actual_doc = in_doc.clone();
344 assert!(trans.apply(&mut actual_doc));
344 assert!(trans.apply(&mut actual_doc));
345 assert_eq!(expected_doc, &actual_doc);
345 assert_eq!(expected_doc, &actual_doc);
helix-core/src/chars.rs+4−5
@@ -91,12 +91,11 @@ mod test {
91
91
92 #[test]
92 #[test]
93 fn test_categorize() {
93 fn test_categorize() {
94− const EOL_TEST_CASE: &'static str = "\n\r\u{000B}\u{000C}\u{0085}\u{2028}\u{2029}";
94+ const EOL_TEST_CASE: &str = "\n\r\u{000B}\u{000C}\u{0085}\u{2028}\u{2029}";
95− const WORD_TEST_CASE: &'static str =
96− "_hello_world_あいうえおー12345678901234567890";
95+ const WORD_TEST_CASE: &str = "_hello_world_あいうえおー12345678901234567890";
97− const PUNCTUATION_TEST_CASE: &'static str =
96+ const PUNCTUATION_TEST_CASE: &str =
98 "!\"#$%&\'()*+,-./:;<=>?@[\\]^`{|}~!”#$%&’()*+、。:;<=>?@「」^`{|}~";
97 "!\"#$%&\'()*+,-./:;<=>?@[\\]^`{|}~!”#$%&’()*+、。:;<=>?@「」^`{|}~";
99− const WHITESPACE_TEST_CASE: &'static str = "      ";
98+ const WHITESPACE_TEST_CASE: &str = "      ";
100
99
101 for ch in EOL_TEST_CASE.chars() {
100 for ch in EOL_TEST_CASE.chars() {
102 assert_eq!(CharCategory::Eol, categorize_char(ch));
101 assert_eq!(CharCategory::Eol, categorize_char(ch));
helix-core/src/diff.rs+1−1
@@ -58,7 +58,7 @@ mod tests {
58 let mut old = Rope::from(a);
58 let mut old = Rope::from(a);
59 let new = Rope::from(b);
59 let new = Rope::from(b);
60 compare_ropes(&old, &new).apply(&mut old);
60 compare_ropes(&old, &new).apply(&mut old);
61− old.to_string() == new.to_string()
61+ old == new
62 }
62 }
63 }
63 }
64}
64}
helix-core/src/history.rs+2−2
@@ -448,8 +448,8 @@ mod test {
448 change: crate::transaction::Change,
448 change: crate::transaction::Change,
449 instant: Instant,
449 instant: Instant,
450 ) {
450 ) {
451− let txn = Transaction::change(&state.doc, vec![change.clone()].into_iter());
451+ let txn = Transaction::change(&state.doc, vec![change].into_iter());
452− history.commit_revision_at_timestamp(&txn, &state, instant);
452+ history.commit_revision_at_timestamp(&txn, state, instant);
453 txn.apply(&mut state.doc);
453 txn.apply(&mut state.doc);
454 }
454 }
455
455
helix-core/src/indent.rs+2−2
@@ -416,7 +416,7 @@ where
416",
416",
417 );
417 );
418
418
419− let doc = Rope::from(doc);
419+ let doc = doc;
420 use crate::diagnostic::Severity;
420 use crate::diagnostic::Severity;
421 use crate::syntax::{
421 use crate::syntax::{
422 Configuration, IndentationConfiguration, LanguageConfiguration, Loader,
422 Configuration, IndentationConfiguration, LanguageConfiguration, Loader,
@@ -454,7 +454,7 @@ where
454
454
455 let language_config = loader.language_config_for_scope("source.rust").unwrap();
455 let language_config = loader.language_config_for_scope("source.rust").unwrap();
456 let highlight_config = language_config.highlight_config(&[]).unwrap();
456 let highlight_config = language_config.highlight_config(&[]).unwrap();
457− let syntax = Syntax::new(&doc, highlight_config.clone(), std::sync::Arc::new(loader));
457+ let syntax = Syntax::new(&doc, highlight_config, std::sync::Arc::new(loader));
458 let text = doc.slice(..);
458 let text = doc.slice(..);
459 let tab_width = 4;
459 let tab_width = 4;
460
460
helix-core/src/line_ending.rs+1−1
@@ -250,7 +250,7 @@ mod line_ending_tests {
250 assert_eq!(get_line_ending_of_str(&text[..6]), Some(LineEnding::CR));
250 assert_eq!(get_line_ending_of_str(&text[..6]), Some(LineEnding::CR));
251 assert_eq!(get_line_ending_of_str(&text[..12]), Some(LineEnding::LF));
251 assert_eq!(get_line_ending_of_str(&text[..12]), Some(LineEnding::LF));
252 assert_eq!(get_line_ending_of_str(&text[..17]), Some(LineEnding::Crlf));
252 assert_eq!(get_line_ending_of_str(&text[..17]), Some(LineEnding::Crlf));
253− assert_eq!(get_line_ending_of_str(&text[..]), None);
253+ assert_eq!(get_line_ending_of_str(text), None);
254 }
254 }
255
255
256 #[test]
256 #[test]
helix-core/src/selection.rs+8−8
@@ -766,16 +766,16 @@ mod test {
766 fn test_contains() {
766 fn test_contains() {
767 let range = Range::new(10, 12);
767 let range = Range::new(10, 12);
768
768
769− assert_eq!(range.contains(9), false);
769+ assert!(!range.contains(9));
770− assert_eq!(range.contains(10), true);
770+ assert!(range.contains(10));
771− assert_eq!(range.contains(11), true);
771+ assert!(range.contains(11));
772− assert_eq!(range.contains(12), false);
772+ assert!(!range.contains(12));
773− assert_eq!(range.contains(13), false);
773+ assert!(!range.contains(13));
774
774
775 let range = Range::new(9, 6);
775 let range = Range::new(9, 6);
776− assert_eq!(range.contains(9), false);
776+ assert!(!range.contains(9));
777− assert_eq!(range.contains(7), true);
777+ assert!(range.contains(7));
778− assert_eq!(range.contains(6), true);
778+ assert!(range.contains(6));
779 }
779 }
780
780
781 #[test]
781 #[test]
helix-core/src/surround.rs+1
@@ -172,6 +172,7 @@ mod test {
172 use ropey::Rope;
172 use ropey::Rope;
173 use smallvec::SmallVec;
173 use smallvec::SmallVec;
174
174
175+ #[allow(clippy::type_complexity)]
175 fn check_find_nth_pair_pos(
176 fn check_find_nth_pair_pos(
176 text: &str,
177 text: &str,
177 cases: Vec<(usize, char, usize, Option<(usize, usize)>)>,
178 cases: Vec<(usize, char, usize, Option<(usize, usize)>)>,
helix-core/src/transaction.rs+1−1
@@ -761,7 +761,7 @@ mod test {
761
761
762 #[test]
762 #[test]
763 fn combine_with_utf8() {
763 fn combine_with_utf8() {
764− const TEST_CASE: &'static str = "Hello, これはヘリックスエディターです!";
764+ const TEST_CASE: &str = "Hello, これはヘリックスエディターです!";
765
765
766 let empty = Rope::from("");
766 let empty = Rope::from("");
767 let a = ChangeSet::new(&empty);
767 let a = ChangeSet::new(&empty);
helix-tui/src/widgets/reflow.rs+2−2
@@ -404,8 +404,8 @@ mod test {
404 let text = "コンピュータ上で文字を扱う場合、典型的には文字による通信を行う場合にその両端点\
404 let text = "コンピュータ上で文字を扱う場合、典型的には文字による通信を行う場合にその両端点\
405 では、";
405 では、";
406 let (word_wrapper, word_wrapper_width) =
406 let (word_wrapper, word_wrapper_width) =
407− run_composer(Composer::WordWrapper { trim: true }, &text, width);
407+ run_composer(Composer::WordWrapper { trim: true }, text, width);
408− let (line_truncator, _) = run_composer(Composer::LineTruncator, &text, width);
408+ let (line_truncator, _) = run_composer(Composer::LineTruncator, text, width);
409 assert_eq!(line_truncator, vec!["コンピュータ上で文字"]);
409 assert_eq!(line_truncator, vec!["コンピュータ上で文字"]);
410 let wrapped = vec![
410 let wrapped = vec![
411 "コンピュータ上で文字",
411 "コンピュータ上で文字",
helix-view/src/view.rs+2−2
@@ -356,7 +356,7 @@ mod tests {
356 let text = rope.slice(..);
356 let text = rope.slice(..);
357
357
358 assert_eq!(
358 assert_eq!(
359− view.text_pos_at_screen_coords(&text, 40, 40 + OFFSET + 0, 4),
359+ view.text_pos_at_screen_coords(&text, 40, 40 + OFFSET, 4),
360 Some(0)
360 Some(0)
361 );
361 );
362
362
@@ -389,7 +389,7 @@ mod tests {
389 let text = rope.slice(..);
389 let text = rope.slice(..);
390
390
391 assert_eq!(
391 assert_eq!(
392− view.text_pos_at_screen_coords(&text, 40, 40 + OFFSET + 0, 4),
392+ view.text_pos_at_screen_coords(&text, 40, 40 + OFFSET, 4),
393 Some(0)
393 Some(0)
394 );
394 );
395
395