Removes unnecessary cwd and pipeline from various tests (#9202)

# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->
Cleans up various tests that unnecessarily use the `cwd` argument of
`nu!`, and the `pipeline` function for single line commands. Also
replaces some unnecessary raw strings with normal strings. Part of
#8670.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->
None

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` to run the tests for the
standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->
All checks pass

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
This commit is contained in:
nicolb2305 2023-05-18 01:55:26 +02:00 committed by GitHub
parent 0e4729b203
commit acd7c98c39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 86 additions and 126 deletions

View File

@ -270,7 +270,7 @@ fn test_computable_style_closure_errors() {
};"#, };"#,
"[bell] | table", "[bell] | table",
]; ];
let actual_repl = nu!(cwd: ".", nu_repl_code(&inp)); let actual_repl = nu!(nu_repl_code(&inp));
// Check that the error was printed // Check that the error was printed
assert!(actual_repl.err.contains("type mismatch for operator")); assert!(actual_repl.err.contains("type mismatch for operator"));
// Check that the value was printed // Check that the value was printed

View File

@ -363,17 +363,17 @@ fn split_words_helper(
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use nu_test_support::{nu, pipeline}; use nu_test_support::nu;
#[test] #[test]
fn test_incompat_flags() { fn test_incompat_flags() {
let out = nu!(cwd: ".", pipeline("'a' | split words -bg -l 2")); let out = nu!("'a' | split words -bg -l 2");
assert!(out.err.contains("incompatible_parameters")); assert!(out.err.contains("incompatible_parameters"));
} }
#[test] #[test]
fn test_incompat_flags_2() { fn test_incompat_flags_2() {
let out = nu!(cwd: ".", pipeline("'a' | split words -g")); let out = nu!("'a' | split words -g");
assert!(out.err.contains("incompatible_parameters")); assert!(out.err.contains("incompatible_parameters"));
} }

View File

@ -71,9 +71,8 @@ fn cant_alias_keyword() {
#[test] #[test]
fn alias_wont_recurse() { fn alias_wont_recurse() {
let actual = nu!( let actual = nu!(pipeline(
cwd: ".", pipeline( "
r#"
module myspamsymbol { module myspamsymbol {
export def myfoosymbol [prefix: string, msg: string] { export def myfoosymbol [prefix: string, msg: string] {
$prefix + $msg $prefix + $msg
@ -82,7 +81,7 @@ fn alias_wont_recurse() {
use myspamsymbol myfoosymbol; use myspamsymbol myfoosymbol;
alias myfoosymbol = myfoosymbol 'hello'; alias myfoosymbol = myfoosymbol 'hello';
myfoosymbol ' world' myfoosymbol ' world'
"# "
)); ));
assert_eq!(actual.out, "hello world"); assert_eq!(actual.out, "hello world");

View File

@ -4,8 +4,8 @@ use nu_test_support::{nu, pipeline};
fn checks_all_rows_are_true() { fn checks_all_rows_are_true() {
let actual = nu!(pipeline( let actual = nu!(pipeline(
r#" r#"
echo [ "Andrés", "Andrés", "Andrés" ] echo [ "Andrés", "Andrés", "Andrés" ]
| all {|it| $it == "Andrés" } | all {|it| $it == "Andrés" }
"# "#
)); ));
@ -14,14 +14,14 @@ fn checks_all_rows_are_true() {
#[test] #[test]
fn checks_all_rows_are_false_with_param() { fn checks_all_rows_are_false_with_param() {
let actual = nu!(r#" [1, 2, 3, 4] | all { |a| $a >= 5 } "#); let actual = nu!(" [1, 2, 3, 4] | all { |a| $a >= 5 } ");
assert_eq!(actual.out, "false"); assert_eq!(actual.out, "false");
} }
#[test] #[test]
fn checks_all_rows_are_true_with_param() { fn checks_all_rows_are_true_with_param() {
let actual = nu!(r#" [1, 2, 3, 4] | all { |a| $a < 5 } "#); let actual = nu!(" [1, 2, 3, 4] | all { |a| $a < 5 } ");
assert_eq!(actual.out, "true"); assert_eq!(actual.out, "true");
} }
@ -29,16 +29,16 @@ fn checks_all_rows_are_true_with_param() {
#[test] #[test]
fn checks_all_columns_of_a_table_is_true() { fn checks_all_columns_of_a_table_is_true() {
let actual = nu!(pipeline( let actual = nu!(pipeline(
r#" "
echo [ echo [
[ first_name, last_name, rusty_at, likes ]; [ first_name, last_name, rusty_at, likes ];
[ Andrés, Robalino, '10/11/2013', 1 ] [ Andrés, Robalino, '10/11/2013', 1 ]
[ JT, Turner, '10/12/2013', 1 ] [ JT, Turner, '10/12/2013', 1 ]
[ Darren, Schroeder, '10/11/2013', 1 ] [ Darren, Schroeder, '10/11/2013', 1 ]
[ Yehuda, Katz, '10/11/2013', 1 ] [ Yehuda, Katz, '10/11/2013', 1 ]
] ]
| all {|x| $x.likes > 0 } | all {|x| $x.likes > 0 }
"# "
)); ));
assert_eq!(actual.out, "true"); assert_eq!(actual.out, "true");
@ -60,35 +60,35 @@ fn checks_if_all_returns_error_with_invalid_command() {
#[test] #[test]
fn works_with_1_param_blocks() { fn works_with_1_param_blocks() {
let actual = nu!(r#"[1 2 3] | all {|e| print $e | true }"#); let actual = nu!("[1 2 3] | all {|e| print $e | true }");
assert_eq!(actual.out, "123true"); assert_eq!(actual.out, "123true");
} }
#[test] #[test]
fn works_with_0_param_blocks() { fn works_with_0_param_blocks() {
let actual = nu!(r#"[1 2 3] | all {|| print $in | true }"#); let actual = nu!("[1 2 3] | all {|| print $in | true }");
assert_eq!(actual.out, "123true"); assert_eq!(actual.out, "123true");
} }
#[test] #[test]
fn early_exits_with_1_param_blocks() { fn early_exits_with_1_param_blocks() {
let actual = nu!(r#"[1 2 3] | all {|e| print $e | false }"#); let actual = nu!("[1 2 3] | all {|e| print $e | false }");
assert_eq!(actual.out, "1false"); assert_eq!(actual.out, "1false");
} }
#[test] #[test]
fn early_exits_with_0_param_blocks() { fn early_exits_with_0_param_blocks() {
let actual = nu!(r#"[1 2 3] | all {|| print $in | false }"#); let actual = nu!("[1 2 3] | all {|| print $in | false }");
assert_eq!(actual.out, "1false"); assert_eq!(actual.out, "1false");
} }
#[test] #[test]
fn all_uses_enumerate_index() { fn all_uses_enumerate_index() {
let actual = nu!(r#"[7 8 9] | enumerate | all {|el| print $el.index | true }"#); let actual = nu!("[7 8 9] | enumerate | all {|el| print $el.index | true }");
assert_eq!(actual.out, "012true"); assert_eq!(actual.out, "012true");
} }

View File

@ -4,8 +4,8 @@ use nu_test_support::{nu, pipeline};
fn checks_any_row_is_true() { fn checks_any_row_is_true() {
let actual = nu!(pipeline( let actual = nu!(pipeline(
r#" r#"
echo [ "Ecuador", "USA", "New Zealand" ] echo [ "Ecuador", "USA", "New Zealand" ]
| any {|it| $it == "New Zealand" } | any {|it| $it == "New Zealand" }
"# "#
)); ));
@ -15,16 +15,16 @@ fn checks_any_row_is_true() {
#[test] #[test]
fn checks_any_column_of_a_table_is_true() { fn checks_any_column_of_a_table_is_true() {
let actual = nu!(pipeline( let actual = nu!(pipeline(
r#" "
echo [ echo [
[ first_name, last_name, rusty_at, likes ]; [ first_name, last_name, rusty_at, likes ];
[ Andrés, Robalino, '10/11/2013', 1 ] [ Andrés, Robalino, '10/11/2013', 1 ]
[ JT, Turner, '10/12/2013', 1 ] [ JT, Turner, '10/12/2013', 1 ]
[ Darren, Schroeder, '10/11/2013', 1 ] [ Darren, Schroeder, '10/11/2013', 1 ]
[ Yehuda, Katz, '10/11/2013', 1 ] [ Yehuda, Katz, '10/11/2013', 1 ]
] ]
| any {|x| $x.rusty_at == '10/12/2013' } | any {|x| $x.rusty_at == '10/12/2013' }
"# "
)); ));
assert_eq!(actual.out, "true"); assert_eq!(actual.out, "true");
@ -46,35 +46,35 @@ fn checks_if_any_returns_error_with_invalid_command() {
#[test] #[test]
fn works_with_1_param_blocks() { fn works_with_1_param_blocks() {
let actual = nu!(r#"[1 2 3] | any {|e| print $e | false }"#); let actual = nu!("[1 2 3] | any {|e| print $e | false }");
assert_eq!(actual.out, "123false"); assert_eq!(actual.out, "123false");
} }
#[test] #[test]
fn works_with_0_param_blocks() { fn works_with_0_param_blocks() {
let actual = nu!(r#"[1 2 3] | any {|| print $in | false }"#); let actual = nu!("[1 2 3] | any {|| print $in | false }");
assert_eq!(actual.out, "123false"); assert_eq!(actual.out, "123false");
} }
#[test] #[test]
fn early_exits_with_1_param_blocks() { fn early_exits_with_1_param_blocks() {
let actual = nu!(r#"[1 2 3] | any {|e| print $e | true }"#); let actual = nu!("[1 2 3] | any {|e| print $e | true }");
assert_eq!(actual.out, "1true"); assert_eq!(actual.out, "1true");
} }
#[test] #[test]
fn early_exits_with_0_param_blocks() { fn early_exits_with_0_param_blocks() {
let actual = nu!(r#"[1 2 3] | any {|| print $in | true }"#); let actual = nu!("[1 2 3] | any {|| print $in | true }");
assert_eq!(actual.out, "1true"); assert_eq!(actual.out, "1true");
} }
#[test] #[test]
fn any_uses_enumerate_index() { fn any_uses_enumerate_index() {
let actual = nu!(r#"[7 8 9] | enumerate | any {|el| print $el.index | false }"#); let actual = nu!("[7 8 9] | enumerate | any {|el| print $el.index | false }");
assert_eq!(actual.out, "012false"); assert_eq!(actual.out, "012false");
} }

View File

@ -2,50 +2,35 @@ use nu_test_support::nu;
#[test] #[test]
fn each_works_separately() { fn each_works_separately() {
let actual = nu!( let actual = nu!("echo [1 2 3] | each { |it| echo $it 10 | math sum } | to json -r");
cwd: "tests/fixtures/formats",
"echo [1 2 3] | each { |it| echo $it 10 | math sum } | to json -r"
);
assert_eq!(actual.out, "[11,12,13]"); assert_eq!(actual.out, "[11,12,13]");
} }
#[test] #[test]
fn each_group_works() { fn each_group_works() {
let actual = nu!( let actual = nu!("echo [1 2 3 4 5 6] | group 3 | to json --raw");
cwd: "tests/fixtures/formats",
"echo [1 2 3 4 5 6] | group 3 | to json --raw"
);
assert_eq!(actual.out, "[[1,2,3],[4,5,6]]"); assert_eq!(actual.out, "[[1,2,3],[4,5,6]]");
} }
#[test] #[test]
fn each_window() { fn each_window() {
let actual = nu!( let actual = nu!("echo [1 2 3 4] | window 3 | to json --raw");
cwd: "tests/fixtures/formats",
"echo [1 2 3 4] | window 3 | to json --raw"
);
assert_eq!(actual.out, "[[1,2,3],[2,3,4]]"); assert_eq!(actual.out, "[[1,2,3],[2,3,4]]");
} }
#[test] #[test]
fn each_window_stride() { fn each_window_stride() {
let actual = nu!( let actual = nu!("echo [1 2 3 4 5 6] | window 3 -s 2 | to json --raw");
cwd: "tests/fixtures/formats",
"echo [1 2 3 4 5 6] | window 3 -s 2 | to json --raw"
);
assert_eq!(actual.out, "[[1,2,3],[3,4,5]]"); assert_eq!(actual.out, "[[1,2,3],[3,4,5]]");
} }
#[test] #[test]
fn each_no_args_in_block() { fn each_no_args_in_block() {
let actual = nu!( let actual = nu!("echo [[foo bar]; [a b] [c d] [e f]] | each {|i| $i | to json -r } | get 1");
cwd: "tests/fixtures/formats",
"echo [[foo bar]; [a b] [c d] [e f]] | each {|i| $i | to json -r } | get 1"
);
assert_eq!(actual.out, r#"{"foo": "c","bar": "d"}"#); assert_eq!(actual.out, r#"{"foo": "c","bar": "d"}"#);
} }
@ -53,7 +38,6 @@ fn each_no_args_in_block() {
#[test] #[test]
fn each_implicit_it_in_block() { fn each_implicit_it_in_block() {
let actual = nu!( let actual = nu!(
cwd: "tests/fixtures/formats",
"echo [[foo bar]; [a b] [c d] [e f]] | each { |it| nu --testbin cococo $it.foo } | str join" "echo [[foo bar]; [a b] [c d] [e f]] | each { |it| nu --testbin cococo $it.foo } | str join"
); );

View File

@ -1,13 +1,8 @@
use nu_test_support::{nu, pipeline}; use nu_test_support::nu;
#[test] #[test]
fn export_subcommands_help() { fn export_subcommands_help() {
let actual = nu!( let actual = nu!("export def -h");
cwd: ".", pipeline(
r#"
export def -h
"#
));
assert!(actual assert!(actual
.out .out

View File

@ -2,29 +2,19 @@ use nu_test_support::{nu, pipeline};
#[test] #[test]
fn string_fill_plain() { fn string_fill_plain() {
let actual = nu!( let actual = nu!(r#""abc" | fill --alignment center --character "+" --width 5"#);
cwd: ".",
pipeline(
r#"
"abc" | fill --alignment center --character "+" --width 5
"#
)
);
assert_eq!(actual.out, "+abc+"); assert_eq!(actual.out, "+abc+");
} }
#[test] #[test]
fn string_fill_fancy() { fn string_fill_fancy() {
let actual = nu!( let actual = nu!(pipeline(
cwd: ".", r#"
pipeline(
r#"
$"(ansi red)a(ansi green)\u{65}\u{308}(ansi cyan)c(ansi reset)" $"(ansi red)a(ansi green)\u{65}\u{308}(ansi cyan)c(ansi reset)"
| fill --alignment center --character "+" --width 5 | fill --alignment center --character "+" --width 5
"# "#
) ));
);
assert_eq!( assert_eq!(
actual.out, actual.out,

View File

@ -68,13 +68,12 @@ fn gets_first_row_when_no_amount_given() {
#[test] #[test]
fn gets_first_row_as_list_when_amount_given() { fn gets_first_row_as_list_when_amount_given() {
let actual = nu!( let actual = nu!(pipeline(
cwd: ".", pipeline(
r#" r#"
[1, 2, 3] [1, 2, 3]
| first 1 | first 1
| describe | describe
"# "#
)); ));
assert_eq!(actual.out, "list<int> (stream)"); assert_eq!(actual.out, "list<int> (stream)");
@ -83,24 +82,18 @@ fn gets_first_row_as_list_when_amount_given() {
#[test] #[test]
// covers a situation where `first` used to behave strangely on list<binary> input // covers a situation where `first` used to behave strangely on list<binary> input
fn works_with_binary_list() { fn works_with_binary_list() {
let actual = nu!( let actual = nu!("([0x[01 11]] | first) == 0x[01 11]");
cwd: ".", pipeline(
r#"
([0x[01 11]] | first) == 0x[01 11]
"#
));
assert_eq!(actual.out, "true"); assert_eq!(actual.out, "true");
} }
#[test] #[test]
fn errors_on_negative_rows() { fn errors_on_negative_rows() {
let actual = nu!( let actual = nu!(pipeline(
cwd: ".", pipeline(
r#" r#"
[1, 2, 3] [1, 2, 3]
| first -10 | first -10
"# "#
)); ));
assert!(actual.err.contains("use a positive value")); assert!(actual.err.contains("use a positive value"));

View File

@ -176,7 +176,7 @@ fn errors_fetching_by_index_out_of_bounds() {
#[test] #[test]
fn errors_fetching_by_accessing_empty_list() { fn errors_fetching_by_accessing_empty_list() {
let actual = nu!(cwd: ".", pipeline(r#"[] | get 3"#)); let actual = nu!("[] | get 3");
assert!(actual.err.contains("Row number too large (empty content)"),); assert!(actual.err.contains("Row number too large (empty content)"),);
} }

View File

@ -19,13 +19,13 @@ fn help_commands_length() {
#[test] #[test]
fn help_shows_signature() { fn help_shows_signature() {
let actual = nu!(cwd: ".", pipeline("help str distance")); let actual = nu!("help str distance");
assert!(actual assert!(actual
.out .out
.contains("<string> | str distance <string> -> <int>")); .contains("<string> | str distance <string> -> <int>"));
// don't show signature for parser keyword // don't show signature for parser keyword
let actual = nu!(cwd: ".", pipeline("help alias")); let actual = nu!("help alias");
assert!(!actual.out.contains("Signatures")); assert!(!actual.out.contains("Signatures"));
} }
@ -36,7 +36,7 @@ fn help_aliases() {
"alias SPAM = print 'spam'", "alias SPAM = print 'spam'",
"help aliases | where name == SPAM | length", "help aliases | where name == SPAM | length",
]; ];
let actual = nu!(cwd: ".", nu_repl_code(code)); let actual = nu!(nu_repl_code(code));
assert_eq!(actual.out, "1"); assert_eq!(actual.out, "1");
} }
@ -289,21 +289,21 @@ fn help_usage_extra_usage_command() {
"#, "#,
)]); )]);
let actual = nu!(cwd: dirs.test(), pipeline("use spam.nu *; help modules spam")); let actual = nu!(cwd: dirs.test(), "use spam.nu *; help modules spam");
assert!(actual.out.contains("module_line1")); assert!(actual.out.contains("module_line1"));
assert!(actual.out.contains("module_line2")); assert!(actual.out.contains("module_line2"));
let actual = nu!(cwd: dirs.test(), let actual = nu!(cwd: dirs.test(),
pipeline("use spam.nu *; help modules | where name == spam | get 0.usage")); "use spam.nu *; help modules | where name == spam | get 0.usage");
assert!(actual.out.contains("module_line1")); assert!(actual.out.contains("module_line1"));
assert!(!actual.out.contains("module_line2")); assert!(!actual.out.contains("module_line2"));
let actual = nu!(cwd: dirs.test(), pipeline("use spam.nu *; help commands foo")); let actual = nu!(cwd: dirs.test(), "use spam.nu *; help commands foo");
assert!(actual.out.contains("def_line1")); assert!(actual.out.contains("def_line1"));
assert!(actual.out.contains("def_line2")); assert!(actual.out.contains("def_line2"));
let actual = nu!(cwd: dirs.test(), let actual = nu!(cwd: dirs.test(),
pipeline("use spam.nu *; help commands | where name == foo | get 0.usage")); "use spam.nu *; help commands | where name == foo | get 0.usage");
assert!(actual.out.contains("def_line1")); assert!(actual.out.contains("def_line1"));
assert!(!actual.out.contains("def_line2")); assert!(!actual.out.contains("def_line2"));
}) })
@ -356,7 +356,7 @@ fn help_modules_main_1() {
"help spam", "help spam",
]; ];
let actual = nu!(cwd: ".", pipeline(&inp.join("; "))); let actual = nu!(&inp.join("; "));
assert!(actual.out.contains(" spam")); assert!(actual.out.contains(" spam"));
} }

View File

@ -84,7 +84,7 @@ fn do_cases_where_result_is_same_between_join_types(join_type: &str) {
(("[{a: 1}]", "[{a: 1 b: 1}]", "a"), "[[a, b]; [1, 1]]"), (("[{a: 1}]", "[{a: 1 b: 1}]", "a"), "[[a, b]; [1, 1]]"),
] { ] {
let expr = format!("{} | join {} {} {} | to nuon", left, right, join_type, on); let expr = format!("{} | join {} {} {} | to nuon", left, right, join_type, on);
let actual = nu!(cwd: ".", expr).out; let actual = nu!(expr).out;
assert_eq!(actual, expected); assert_eq!(actual, expected);
// Test again with streaming input (using `each` to convert the input into a ListStream) // Test again with streaming input (using `each` to convert the input into a ListStream)
@ -93,7 +93,7 @@ fn do_cases_where_result_is_same_between_join_types(join_type: &str) {
"{} | {} join {} {} {} | to nuon", "{} | {} join {} {} {} | to nuon",
left, to_list_stream, right, join_type, on left, to_list_stream, right, join_type, on
); );
let actual = nu!(cwd: ".", expr).out; let actual = nu!(expr).out;
assert_eq!(actual, expected); assert_eq!(actual, expected);
} }
} }
@ -199,7 +199,7 @@ fn do_cases_where_result_differs_between_join_types(join_type: &str) {
for (join_type_, expected) in join_types { for (join_type_, expected) in join_types {
if join_type_ == join_type { if join_type_ == join_type {
let expr = format!("{} | join {} {} {} | to nuon", left, right, join_type, on); let expr = format!("{} | join {} {} {} | to nuon", left, right, join_type, on);
let actual = nu!(cwd: ".", expr).out; let actual = nu!(expr).out;
assert_eq!(actual, expected); assert_eq!(actual, expected);
// Test again with streaming input (using `each` to convert the input into a ListStream) // Test again with streaming input (using `each` to convert the input into a ListStream)
@ -208,7 +208,7 @@ fn do_cases_where_result_differs_between_join_types(join_type: &str) {
"{} | {} join {} {} {} | to nuon", "{} | {} join {} {} {} | to nuon",
left, to_list_stream, right, join_type, on left, to_list_stream, right, join_type, on
); );
let actual = nu!(cwd: ".", expr).out; let actual = nu!(expr).out;
assert_eq!(actual, expected); assert_eq!(actual, expected);
} }
} }
@ -339,7 +339,7 @@ fn do_cases_where_result_differs_between_join_types_with_different_join_keys(joi
for (join_type_, expected) in join_types { for (join_type_, expected) in join_types {
if join_type_ == join_type { if join_type_ == join_type {
let expr = format!("{} | join {} {} {} {} | to nuon", left, right, join_type, left_on, right_on); let expr = format!("{} | join {} {} {} {} | to nuon", left, right, join_type, left_on, right_on);
let actual = nu!(cwd: ".", expr).out; let actual = nu!(expr).out;
assert_eq!(actual, expected); assert_eq!(actual, expected);
// Test again with streaming input (using `each` to convert the input into a ListStream) // Test again with streaming input (using `each` to convert the input into a ListStream)
@ -348,7 +348,7 @@ fn do_cases_where_result_differs_between_join_types_with_different_join_keys(joi
"{} | {} join {} {} {} {} | to nuon", "{} | {} join {} {} {} {} | to nuon",
left, to_list_stream, right, join_type, left_on, right_on left, to_list_stream, right, join_type, left_on, right_on
); );
let actual = nu!(cwd: ".", expr).out; let actual = nu!(expr).out;
assert_eq!(actual, expected); assert_eq!(actual, expected);
} }
} }
@ -366,7 +366,7 @@ fn test_alternative_table_syntax() {
(("[[a]; [1]]", "[[a]; [1]]", "a"), "[[a]; [1]]"), (("[[a]; [1]]", "[[a]; [1]]", "a"), "[[a]; [1]]"),
] { ] {
let expr = format!("{} | join {} {} {} | to nuon", left, right, join_type, on); let expr = format!("{} | join {} {} {} | to nuon", left, right, join_type, on);
let actual = nu!(cwd: ".", &expr).out; let actual = nu!(&expr).out;
assert_eq!(actual, expected, "Expression was {}", &expr); assert_eq!(actual, expected, "Expression was {}", &expr);
} }
} }

View File

@ -81,12 +81,11 @@ fn gets_last_row_as_list_when_amount_given() {
#[test] #[test]
fn last_errors_on_negative_index() { fn last_errors_on_negative_index() {
let actual = nu!( let actual = nu!(pipeline(
cwd: ".", pipeline( "
r#" [1, 2, 3]
[1, 2, 3] | last -2
| last -2 "
"#
)); ));
assert!(actual.err.contains("use a positive value")); assert!(actual.err.contains("use a positive value"));
@ -94,7 +93,7 @@ fn last_errors_on_negative_index() {
#[test] #[test]
fn fail_on_non_iterator() { fn fail_on_non_iterator() {
let actual = nu!(cwd: ".", pipeline("1 | last")); let actual = nu!("1 | last");
assert!(actual.err.contains("only_supports_this_input_type")); assert!(actual.err.contains("only_supports_this_input_type"));
} }