on master help sign in
Fix Clippy lints in tests (#1563)

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>

commitf064894e5778071ef8cc563380f48cfdd9acba59 authorOmnikar <omnikar5@gmail.com> dateSun 23 Jan 2022, 02:37 (5 years ago) parente2d2f19
11 files changed+26−26
helix-core/src/auto_pairs.rs+2−2 helix-core/src/chars.rs+4−5 helix-core/src/diff.rs+1−1 helix-core/src/history.rs+2−2 helix-core/src/indent.rs+2−2 helix-core/src/line_ending.rs+1−1 helix-core/src/selection.rs+8−8 helix-core/src/surround.rs+1 helix-core/src/transaction.rs+1−1 helix-tui/src/widgets/reflow.rs+2−2 helix-view/src/view.rs+2−2
helix-core/src/auto_pairs.rs+2−2
@@ -322,7 +322,7 @@ mod test {
322322 use super::*;
323323 use smallvec::smallvec;
324324
325− const LINE_END: &'static str = crate::DEFAULT_LINE_ENDING.as_str();
325+ const LINE_END: &str = crate::DEFAULT_LINE_ENDING.as_str();
326326
327327 fn differing_pairs() -> impl Iterator<Item = &'static (char, char)> {
328328 PAIRS.iter().filter(|(open, close)| open != close)
@@ -339,7 +339,7 @@ mod test {
339339 expected_doc: &Rope,
340340 expected_sel: &Selection,
341341 ) {
342− let trans = hook(&in_doc, &in_sel, ch).unwrap();
342+ let trans = hook(in_doc, in_sel, ch).unwrap();
343343 let mut actual_doc = in_doc.clone();
344344 assert!(trans.apply(&mut actual_doc));
345345 assert_eq!(expected_doc, &actual_doc);
helix-core/src/chars.rs+4−5
@@ -91,12 +91,11 @@ mod test {
9191
9292 #[test]
9393 fn test_categorize() {
94− const EOL_TEST_CASE: &'static str = "\n\r\u{000B}\u{000C}\u{0085}\u{2028}\u{2029}";
95− const WORD_TEST_CASE: &'static str =
96− "_hello_world_あいうえおー12345678901234567890";
97− const PUNCTUATION_TEST_CASE: &'static str =
94+ const EOL_TEST_CASE: &str = "\n\r\u{000B}\u{000C}\u{0085}\u{2028}\u{2029}";
95+ const WORD_TEST_CASE: &str = "_hello_world_あいうえおー12345678901234567890";
96+ const PUNCTUATION_TEST_CASE: &str =
9897 "!\"#$%&\'()*+,-./:;<=>?@[\\]^`{|}~!”#$%&’()*+、。:;<=>?@「」^`{|}~";
99− const WHITESPACE_TEST_CASE: &'static str = "      ";
98+ const WHITESPACE_TEST_CASE: &str = "      ";
10099
101100 for ch in EOL_TEST_CASE.chars() {
102101 assert_eq!(CharCategory::Eol, categorize_char(ch));
helix-core/src/diff.rs+1−1
@@ -58,7 +58,7 @@ mod tests {
5858 let mut old = Rope::from(a);
5959 let new = Rope::from(b);
6060 compare_ropes(&old, &new).apply(&mut old);
61− old.to_string() == new.to_string()
61+ old == new
6262 }
6363 }
6464}
helix-core/src/history.rs+2−2
@@ -448,8 +448,8 @@ mod test {
448448 change: crate::transaction::Change,
449449 instant: Instant,
450450 ) {
451− let txn = Transaction::change(&state.doc, vec![change.clone()].into_iter());
452− history.commit_revision_at_timestamp(&txn, &state, instant);
451+ let txn = Transaction::change(&state.doc, vec![change].into_iter());
452+ history.commit_revision_at_timestamp(&txn, state, instant);
453453 txn.apply(&mut state.doc);
454454 }
455455
helix-core/src/indent.rs+2−2
@@ -416,7 +416,7 @@ where
416416",
417417 );
418418
419− let doc = Rope::from(doc);
419+ let doc = doc;
420420 use crate::diagnostic::Severity;
421421 use crate::syntax::{
422422 Configuration, IndentationConfiguration, LanguageConfiguration, Loader,
@@ -454,7 +454,7 @@ where
454454
455455 let language_config = loader.language_config_for_scope("source.rust").unwrap();
456456 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));
458458 let text = doc.slice(..);
459459 let tab_width = 4;
460460
helix-core/src/line_ending.rs+1−1
@@ -250,7 +250,7 @@ mod line_ending_tests {
250250 assert_eq!(get_line_ending_of_str(&text[..6]), Some(LineEnding::CR));
251251 assert_eq!(get_line_ending_of_str(&text[..12]), Some(LineEnding::LF));
252252 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);
254254 }
255255
256256 #[test]
helix-core/src/selection.rs+8−8
@@ -766,16 +766,16 @@ mod test {
766766 fn test_contains() {
767767 let range = Range::new(10, 12);
768768
769− assert_eq!(range.contains(9), false);
770− assert_eq!(range.contains(10), true);
771− assert_eq!(range.contains(11), true);
772− assert_eq!(range.contains(12), false);
773− assert_eq!(range.contains(13), false);
769+ assert!(!range.contains(9));
770+ assert!(range.contains(10));
771+ assert!(range.contains(11));
772+ assert!(!range.contains(12));
773+ assert!(!range.contains(13));
774774
775775 let range = Range::new(9, 6);
776− assert_eq!(range.contains(9), false);
777− assert_eq!(range.contains(7), true);
778− assert_eq!(range.contains(6), true);
776+ assert!(!range.contains(9));
777+ assert!(range.contains(7));
778+ assert!(range.contains(6));
779779 }
780780
781781 #[test]
helix-core/src/surround.rs+1
@@ -172,6 +172,7 @@ mod test {
172172 use ropey::Rope;
173173 use smallvec::SmallVec;
174174
175+ #[allow(clippy::type_complexity)]
175176 fn check_find_nth_pair_pos(
176177 text: &str,
177178 cases: Vec<(usize, char, usize, Option<(usize, usize)>)>,
helix-core/src/transaction.rs+1−1
@@ -761,7 +761,7 @@ mod test {
761761
762762 #[test]
763763 fn combine_with_utf8() {
764− const TEST_CASE: &'static str = "Hello, これはヘリックスエディターです!";
764+ const TEST_CASE: &str = "Hello, これはヘリックスエディターです!";
765765
766766 let empty = Rope::from("");
767767 let a = ChangeSet::new(&empty);
helix-tui/src/widgets/reflow.rs+2−2
@@ -404,8 +404,8 @@ mod test {
404404 let text = "コンピュータ上で文字を扱う場合、典型的には文字による通信を行う場合にその両端点\
405405 では、";
406406 let (word_wrapper, word_wrapper_width) =
407− run_composer(Composer::WordWrapper { trim: true }, &text, width);
408− let (line_truncator, _) = run_composer(Composer::LineTruncator, &text, width);
407+ run_composer(Composer::WordWrapper { trim: true }, text, width);
408+ let (line_truncator, _) = run_composer(Composer::LineTruncator, text, width);
409409 assert_eq!(line_truncator, vec!["コンピュータ上で文字"]);
410410 let wrapped = vec![
411411 "コンピュータ上で文字",
helix-view/src/view.rs+2−2
@@ -356,7 +356,7 @@ mod tests {
356356 let text = rope.slice(..);
357357
358358 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),
360360 Some(0)
361361 );
362362
@@ -389,7 +389,7 @@ mod tests {
389389 let text = rope.slice(..);
390390
391391 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),
393393 Some(0)
394394 );
395395