Skip to content

Commit

Permalink
Fix Clippy lints in tests (helix-editor#1563)
Browse files Browse the repository at this point in the history
Co-authored-by: Blaž Hrastnik <[email protected]>
  • Loading branch information
Omnikar and archseer authored Jan 23, 2022
1 parent e2d2f19 commit f064894
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions helix-core/src/auto_pairs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ mod test {
use super::*;
use smallvec::smallvec;

const LINE_END: &'static str = crate::DEFAULT_LINE_ENDING.as_str();
const LINE_END: &str = crate::DEFAULT_LINE_ENDING.as_str();

fn differing_pairs() -> impl Iterator<Item = &'static (char, char)> {
PAIRS.iter().filter(|(open, close)| open != close)
Expand All @@ -339,7 +339,7 @@ mod test {
expected_doc: &Rope,
expected_sel: &Selection,
) {
let trans = hook(&in_doc, &in_sel, ch).unwrap();
let trans = hook(in_doc, in_sel, ch).unwrap();
let mut actual_doc = in_doc.clone();
assert!(trans.apply(&mut actual_doc));
assert_eq!(expected_doc, &actual_doc);
Expand Down
9 changes: 4 additions & 5 deletions helix-core/src/chars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,11 @@ mod test {

#[test]
fn test_categorize() {
const EOL_TEST_CASE: &'static str = "\n\r\u{000B}\u{000C}\u{0085}\u{2028}\u{2029}";
const WORD_TEST_CASE: &'static str =
"_hello_world_あいうえおー12345678901234567890";
const PUNCTUATION_TEST_CASE: &'static str =
const EOL_TEST_CASE: &str = "\n\r\u{000B}\u{000C}\u{0085}\u{2028}\u{2029}";
const WORD_TEST_CASE: &str = "_hello_world_あいうえおー12345678901234567890";
const PUNCTUATION_TEST_CASE: &str =
"!\"#$%&\'()*+,-./:;<=>?@[\\]^`{|}~!”#$%&’()*+、。:;<=>?@「」^`{|}~";
const WHITESPACE_TEST_CASE: &'static str = "      ";
const WHITESPACE_TEST_CASE: &str = "      ";

for ch in EOL_TEST_CASE.chars() {
assert_eq!(CharCategory::Eol, categorize_char(ch));
Expand Down
2 changes: 1 addition & 1 deletion helix-core/src/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ mod tests {
let mut old = Rope::from(a);
let new = Rope::from(b);
compare_ropes(&old, &new).apply(&mut old);
old.to_string() == new.to_string()
old == new
}
}
}
4 changes: 2 additions & 2 deletions helix-core/src/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,8 @@ mod test {
change: crate::transaction::Change,
instant: Instant,
) {
let txn = Transaction::change(&state.doc, vec![change.clone()].into_iter());
history.commit_revision_at_timestamp(&txn, &state, instant);
let txn = Transaction::change(&state.doc, vec![change].into_iter());
history.commit_revision_at_timestamp(&txn, state, instant);
txn.apply(&mut state.doc);
}

Expand Down
4 changes: 2 additions & 2 deletions helix-core/src/indent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ where
",
);

let doc = Rope::from(doc);
let doc = doc;
use crate::diagnostic::Severity;
use crate::syntax::{
Configuration, IndentationConfiguration, LanguageConfiguration, Loader,
Expand Down Expand Up @@ -454,7 +454,7 @@ where

let language_config = loader.language_config_for_scope("source.rust").unwrap();
let highlight_config = language_config.highlight_config(&[]).unwrap();
let syntax = Syntax::new(&doc, highlight_config.clone(), std::sync::Arc::new(loader));
let syntax = Syntax::new(&doc, highlight_config, std::sync::Arc::new(loader));
let text = doc.slice(..);
let tab_width = 4;

Expand Down
2 changes: 1 addition & 1 deletion helix-core/src/line_ending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ mod line_ending_tests {
assert_eq!(get_line_ending_of_str(&text[..6]), Some(LineEnding::CR));
assert_eq!(get_line_ending_of_str(&text[..12]), Some(LineEnding::LF));
assert_eq!(get_line_ending_of_str(&text[..17]), Some(LineEnding::Crlf));
assert_eq!(get_line_ending_of_str(&text[..]), None);
assert_eq!(get_line_ending_of_str(text), None);
}

#[test]
Expand Down
16 changes: 8 additions & 8 deletions helix-core/src/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,16 +766,16 @@ mod test {
fn test_contains() {
let range = Range::new(10, 12);

assert_eq!(range.contains(9), false);
assert_eq!(range.contains(10), true);
assert_eq!(range.contains(11), true);
assert_eq!(range.contains(12), false);
assert_eq!(range.contains(13), false);
assert!(!range.contains(9));
assert!(range.contains(10));
assert!(range.contains(11));
assert!(!range.contains(12));
assert!(!range.contains(13));

let range = Range::new(9, 6);
assert_eq!(range.contains(9), false);
assert_eq!(range.contains(7), true);
assert_eq!(range.contains(6), true);
assert!(!range.contains(9));
assert!(range.contains(7));
assert!(range.contains(6));
}

#[test]
Expand Down
1 change: 1 addition & 0 deletions helix-core/src/surround.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ mod test {
use ropey::Rope;
use smallvec::SmallVec;

#[allow(clippy::type_complexity)]
fn check_find_nth_pair_pos(
text: &str,
cases: Vec<(usize, char, usize, Option<(usize, usize)>)>,
Expand Down
2 changes: 1 addition & 1 deletion helix-core/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ mod test {

#[test]
fn combine_with_utf8() {
const TEST_CASE: &'static str = "Hello, これはヘリックスエディターです!";
const TEST_CASE: &str = "Hello, これはヘリックスエディターです!";

let empty = Rope::from("");
let a = ChangeSet::new(&empty);
Expand Down
4 changes: 2 additions & 2 deletions helix-tui/src/widgets/reflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,8 @@ mod test {
let text = "コンピュータ上で文字を扱う場合、典型的には文字による通信を行う場合にその両端点\
では、";
let (word_wrapper, word_wrapper_width) =
run_composer(Composer::WordWrapper { trim: true }, &text, width);
let (line_truncator, _) = run_composer(Composer::LineTruncator, &text, width);
run_composer(Composer::WordWrapper { trim: true }, text, width);
let (line_truncator, _) = run_composer(Composer::LineTruncator, text, width);
assert_eq!(line_truncator, vec!["コンピュータ上で文字"]);
let wrapped = vec![
"コンピュータ上で文字",
Expand Down
4 changes: 2 additions & 2 deletions helix-view/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ mod tests {
let text = rope.slice(..);

assert_eq!(
view.text_pos_at_screen_coords(&text, 40, 40 + OFFSET + 0, 4),
view.text_pos_at_screen_coords(&text, 40, 40 + OFFSET, 4),
Some(0)
);

Expand Down Expand Up @@ -389,7 +389,7 @@ mod tests {
let text = rope.slice(..);

assert_eq!(
view.text_pos_at_screen_coords(&text, 40, 40 + OFFSET + 0, 4),
view.text_pos_at_screen_coords(&text, 40, 40 + OFFSET, 4),
Some(0)
);

Expand Down

0 comments on commit f064894

Please sign in to comment.