From 43905caa46803833b4010f10b64abafb1fae9a9b Mon Sep 17 00:00:00 2001 From: JT <547158+jntrnr@users.noreply.github.com> Date: Mon, 26 Sep 2022 09:06:13 +1300 Subject: [PATCH] touchup some clippy warnings in tests (#6612) --- crates/nu-cli/tests/completions.rs | 8 ++++---- crates/nu-command/tests/commands/source_env.rs | 2 +- crates/nu-command/tests/format_conversions/nuon.rs | 2 +- crates/nu-plugin/benches/encoder_benchmark.rs | 2 +- crates/nu-test-support/tests/get_system_locale.rs | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/nu-cli/tests/completions.rs b/crates/nu-cli/tests/completions.rs index ab85eb51fd12..372315960749 100644 --- a/crates/nu-cli/tests/completions.rs +++ b/crates/nu-cli/tests/completions.rs @@ -114,7 +114,7 @@ fn external_completer_trailing_space() { let block = "let external_completer = {|spans| $spans}"; let input = "gh alias ".to_string(); - let suggestions = run_external_completion(&block, &input); + let suggestions = run_external_completion(block, &input); assert_eq!(3, suggestions.len()); assert_eq!("gh", suggestions.get(0).unwrap().value); assert_eq!("alias", suggestions.get(1).unwrap().value); @@ -126,7 +126,7 @@ fn external_completer_no_trailing_space() { let block = "let external_completer = {|spans| $spans}"; let input = "gh alias".to_string(); - let suggestions = run_external_completion(&block, &input); + let suggestions = run_external_completion(block, &input); assert_eq!(2, suggestions.len()); assert_eq!("gh", suggestions.get(0).unwrap().value); assert_eq!("alias", suggestions.get(1).unwrap().value); @@ -137,7 +137,7 @@ fn external_completer_pass_flags() { let block = "let external_completer = {|spans| $spans}"; let input = "gh api --".to_string(); - let suggestions = run_external_completion(&block, &input); + let suggestions = run_external_completion(block, &input); assert_eq!(3, suggestions.len()); assert_eq!("gh", suggestions.get(0).unwrap().value); assert_eq!("api", suggestions.get(1).unwrap().value); @@ -637,7 +637,7 @@ fn run_external_completion(block: &str, input: &str) -> Vec { // Instatiate a new completer let mut completer = NuCompleter::new(std::sync::Arc::new(engine_state), stack); - completer.complete(&input, input.len()) + completer.complete(input, input.len()) } #[test] diff --git a/crates/nu-command/tests/commands/source_env.rs b/crates/nu-command/tests/commands/source_env.rs index a0f99086e105..ace33f25b78f 100644 --- a/crates/nu-command/tests/commands/source_env.rs +++ b/crates/nu-command/tests/commands/source_env.rs @@ -149,7 +149,7 @@ fn can_source_dynamic_path() { Playground::setup("can_source_dynamic_path", |dirs, sandbox| { let foo_file = "foo.nu"; - sandbox.with_files(vec![FileWithContent(&foo_file, "echo foo")]); + sandbox.with_files(vec![FileWithContent(foo_file, "echo foo")]); let cmd = format!("let file = `{}`; source-env $file", foo_file); let actual = nu!(cwd: dirs.test(), &cmd); diff --git a/crates/nu-command/tests/format_conversions/nuon.rs b/crates/nu-command/tests/format_conversions/nuon.rs index 42729d8376fb..77f7b71517fa 100644 --- a/crates/nu-command/tests/format_conversions/nuon.rs +++ b/crates/nu-command/tests/format_conversions/nuon.rs @@ -289,7 +289,7 @@ proptest! { } #[test] fn to_nuon_from_nuon_string(s: String) { - if s != "\\0" && s!= "" && !s.contains('\\') && !s.contains('"'){ + if s != "\\0" && !s.is_empty() && !s.contains('\\') && !s.contains('"'){ let actual = nu!( cwd: "tests/fixtures/formats", pipeline( format!(r#" diff --git a/crates/nu-plugin/benches/encoder_benchmark.rs b/crates/nu-plugin/benches/encoder_benchmark.rs index acc026f0f952..63f3650e5f20 100644 --- a/crates/nu-plugin/benches/encoder_benchmark.rs +++ b/crates/nu-plugin/benches/encoder_benchmark.rs @@ -5,7 +5,7 @@ use nu_protocol::{Span, Value}; // generate a new table data with `row_cnt` rows, `col_cnt` columns. fn new_test_data(row_cnt: usize, col_cnt: usize) -> Value { let columns: Vec = (0..col_cnt).map(|x| format!("col_{x}")).collect(); - let vals: Vec = (0..col_cnt as i64).map(|i| Value::test_int(i)).collect(); + let vals: Vec = (0..col_cnt as i64).map(Value::test_int).collect(); Value::List { vals: (0..row_cnt) diff --git a/crates/nu-test-support/tests/get_system_locale.rs b/crates/nu-test-support/tests/get_system_locale.rs index 862b9441816a..eb90bb1bab28 100644 --- a/crates/nu-test-support/tests/get_system_locale.rs +++ b/crates/nu-test-support/tests/get_system_locale.rs @@ -4,7 +4,7 @@ use num_format::Grouping; #[test] fn test_get_system_locale_en() { - let locale = with_locale_override("en_US.UTF-8", || get_system_locale()); + let locale = with_locale_override("en_US.UTF-8", get_system_locale); assert_eq!(locale.name(), "en"); assert_eq!(locale.grouping(), Grouping::Standard) @@ -12,7 +12,7 @@ fn test_get_system_locale_en() { #[test] fn test_get_system_locale_de() { - let locale = with_locale_override("de_DE.UTF-8", || get_system_locale()); + let locale = with_locale_override("de_DE.UTF-8", get_system_locale); assert_eq!(locale.name(), "de"); assert_eq!(locale.grouping(), Grouping::Standard)