nushell/crates/nu-command/tests/commands/rotate.rs
Dan Davison 4926865c4e
str collect => str join (#6531)
* Initialize join.rs as a copy of collect.rs

* Evolve StrCollect into StrJoin

* Replace 'str collect' with 'str join' everywhere

git ls-files | lines | par-each { |it| sed -i 's,str collect,str join,g' $it }

* Deprecate 'str collect'

* Revert "Deprecate 'str collect'"

This reverts commit 959d14203e.

* Change `str collect` help message to say that it is deprecated

We cannot remove `str collect` currently (i.e. via
`nu_protocol::ShellError::DeprecatedCommand` since a prominent project
uses the API:

b85542c31c/src/virtualenv/activation/nushell/activate.nu (L43)
2022-09-11 11:48:27 +03:00

84 lines
1.9 KiB
Rust

use nu_test_support::{nu, pipeline};
#[test]
fn counter_clockwise() {
let table = pipeline(
r#"
echo [
[col1, col2, EXPECTED];
[---, "|||", XX1]
[---, "|||", XX2]
[---, "|||", XX3]
]
"#,
);
let expected = nu!(cwd: ".", pipeline(
r#"
echo [
[ column0, column1, column2, column3];
[ EXPECTED, XX1, XX2, XX3]
[ col2, "|||", "|||", "|||"]
[ col1, ---, ---, ---]
]
| where column0 == EXPECTED
| get column1 column2 column3
| str join "-"
"#,
));
let actual = nu!(
cwd: ".",
format!("{} | {}", table, pipeline(r#"
rotate --ccw
| where column0 == EXPECTED
| get column1 column2 column3
| str join "-"
"#)));
assert_eq!(actual.out, expected.out);
}
#[test]
fn clockwise() {
let table = pipeline(
r#"
echo [
[col1, col2, EXPECTED];
[ ---, "|||", XX1]
[ ---, "|||", XX2]
[ ---, "|||", XX3]
]
"#,
);
let expected = nu!(cwd: ".", pipeline(
r#"
echo [
[ column0, column1, column2, column3];
[ ---, ---, ---, col1]
[ "|||", "|||", "|||", col2]
[ XX3, XX2, XX1, EXPECTED]
]
| where column3 == EXPECTED
| get column0 column1 column2
| str join "-"
"#,
));
let actual = nu!(
cwd: ".",
format!("{} | {}", table, pipeline(r#"
rotate
| where column3 == EXPECTED
| get column0 column1 column2
| str join "-"
"#)));
assert_eq!(actual.out, expected.out);
}