mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 14:25:55 +02:00
Make str collect
take an optional separator value (#2289)
* Make `str collect` take an optional separator value * Make `str collect` take an optional separator value * Add some tests * Fix my tests
This commit is contained in:
53
crates/nu-cli/tests/commands/str_/collect.rs
Normal file
53
crates/nu-cli/tests/commands/str_/collect.rs
Normal file
@ -0,0 +1,53 @@
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn test_1() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 1..5 | str from | str collect
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "12345");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_2() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [a b c d] | str collect "<sep>"
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "a<sep>b<sep>c<sep>d");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn construct_a_path() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo [sample txt] | str collect "."
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "sample.txt");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sum_one_to_four() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 1..4 | str from | str collect "+" | math eval
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert!(actual.out.contains("10.0"));
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
mod collect;
|
||||
|
||||
use nu_test_support::fs::Stub::FileWithContent;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
Reference in New Issue
Block a user