mirror of
https://github.com/nushell/nushell.git
synced 2024-12-01 21:03:58 +01:00
3481c7e242
# Description This command also flat-maps and doesn't create a table like `split column` We should probably reconsider the flatmap behavior like in #9739 but for the #9812 hotfix this is an unwelcome breaking change. # User-Facing Changes None # Tests + Formatting - Fix signature of `split row` - Add test for output signature
59 lines
1.5 KiB
Rust
59 lines
1.5 KiB
Rust
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
|
use nu_test_support::playground::Playground;
|
|
use nu_test_support::{nu, pipeline};
|
|
|
|
#[test]
|
|
fn to_row() {
|
|
Playground::setup("split_row_test_1", |dirs, sandbox| {
|
|
sandbox.with_files(vec![
|
|
FileWithContentToBeTrimmed(
|
|
"sample.txt",
|
|
r#"
|
|
importer,shipper,tariff_item,name,origin
|
|
"#,
|
|
),
|
|
FileWithContentToBeTrimmed(
|
|
"sample2.txt",
|
|
r#"
|
|
importer , shipper , tariff_item,name , origin
|
|
"#,
|
|
),
|
|
]);
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
open sample.txt
|
|
| lines
|
|
| str trim
|
|
| split row ","
|
|
| length
|
|
"#
|
|
));
|
|
|
|
assert!(actual.out.contains('5'));
|
|
|
|
let actual = nu!(
|
|
cwd: dirs.test(), pipeline(
|
|
r#"
|
|
open sample2.txt
|
|
| lines
|
|
| str trim
|
|
| split row -r '\s*,\s*'
|
|
| length
|
|
"#
|
|
));
|
|
|
|
assert!(actual.out.contains('5'));
|
|
|
|
let actual = nu!(r#"
|
|
def foo [a: list<string>] {
|
|
$a | describe
|
|
}
|
|
foo (["a b", "c d"] | split row " ")
|
|
"#);
|
|
|
|
assert!(actual.out.contains("list<string>"));
|
|
})
|
|
}
|