2020-08-02 09:29:29 +02:00
|
|
|
use nu_test_support::{nu, pipeline};
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_1() {
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: ".", pipeline(
|
|
|
|
r#"
|
2021-05-27 19:18:02 +02:00
|
|
|
echo 1..5 | into string | str collect
|
2020-08-02 09:29:29 +02:00
|
|
|
"#
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
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#"
|
2022-02-17 12:40:24 +01:00
|
|
|
1..4 | each { |it| $it } | into string | str collect "+" | math eval
|
2020-08-02 09:29:29 +02:00
|
|
|
"#
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2022-02-04 03:01:45 +01:00
|
|
|
assert!(actual.out.contains("10"));
|
2020-08-02 09:29:29 +02:00
|
|
|
}
|