Remove trim in favor of str trim (#2560)

This commit is contained in:
Chris Gillespie
2020-09-16 12:59:32 -07:00
committed by GitHub
parent d05f9b3b1e
commit 50cbf91bc5
16 changed files with 14 additions and 263 deletions

View File

@ -6,7 +6,7 @@ use nu_test_support::{nu, pipeline};
fn gets_the_last_row() {
let actual = nu!(
cwd: "tests/fixtures/formats",
"ls | sort-by name | last 1 | get name | trim | echo $it"
"ls | sort-by name | last 1 | get name | str trim | echo $it"
);
assert_eq!(actual.out, "utf16.ini");

View File

@ -12,7 +12,7 @@ fn lines() {
| first 1
| split column "="
| get Column1
| trim
| str trim
| echo $it
"#
));

View File

@ -50,7 +50,6 @@ mod split_column;
mod split_row;
mod str_;
mod touch;
mod trim;
mod uniq;
mod update;
mod where_;

View File

@ -25,7 +25,7 @@ fn moves_a_column_before() {
| move column column99 --before column1
| rename chars
| get chars
| trim
| str trim
| str collect
| echo $it
"#
@ -60,7 +60,7 @@ fn moves_columns_before() {
| move column column99 column3 --before column2
| rename _ chars_1 chars_2
| get chars_2 chars_1
| trim
| str trim
| str collect
| echo $it
"#
@ -96,7 +96,7 @@ fn moves_a_column_after() {
| move column letters and_more --before column2
| rename _ chars_1 chars_2
| get chars_1 chars_2
| trim
| str trim
| str collect
| echo $it
"#

View File

@ -4,7 +4,7 @@ use nu_test_support::nu;
fn can_get_reverse_first() {
let actual = nu!(
cwd: "tests/fixtures/formats",
"ls | sort-by name | reverse | first 1 | get name | trim | echo $it"
"ls | sort-by name | reverse | first 1 | get name | str trim | echo $it"
);
assert_eq!(actual.out, "utf16.ini");

View File

@ -14,7 +14,7 @@ fn by_column() {
| skip 1
| first 1
| get Column1
| trim
| str trim
| echo $it
"#
));
@ -36,7 +36,7 @@ fn by_invalid_column() {
| skip 1
| first 1
| get Column1
| trim
| str trim
| echo $it
"#
));

View File

@ -17,7 +17,7 @@ fn to_column() {
r#"
open sample.txt
| lines
| trim
| str trim
| split column ","
| get Column2
| echo $it

View File

@ -17,7 +17,7 @@ fn to_row() {
r#"
open sample.txt
| lines
| trim
| str trim
| split row ","
| count
| echo $it

View File

@ -1,85 +0,0 @@
use nu_test_support::fs::Stub::FileWithContent;
use nu_test_support::playground::Playground;
use nu_test_support::{nu, pipeline};
#[test]
fn string() {
Playground::setup("trim_test_1", |dirs, _sandbox| {
let test_strings = ["\n", " \n ", "\thi\n\n", "\u{2003}a"];
assert!(test_strings[3].chars().count() == 2);
for test_string in &test_strings {
let commandline = format!(
r#"
echo {}
| trim
"#,
test_string
);
let actual = nu!(
cwd: dirs.test(), pipeline(&commandline
));
assert_eq!(actual.out, test_string.trim())
}
})
}
#[test]
fn row() {
Playground::setup("trim_test_2", |dirs, sandbox| {
sandbox.with_files(vec![
FileWithContent("lines.csv", "lines\n l0\n\tl1\n l2\t \n\n"),
FileWithContent("lines_trimmed.csv", "lines\nl0\nl1\nl2\n"),
]);
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
open lines.csv
| trim
"#
));
let expected = nu!(
cwd: dirs.test(), pipeline(
r#"
open lines_trimmed.csv
"#
));
assert_eq!(actual.out, expected.out)
})
}
#[test]
fn nested() {
Playground::setup("trim_test_3", |dirs, sandbox| {
sandbox.with_files(vec![
FileWithContent(
"nested.json",
r#"{ "l0" : {"l1": {"l2" : {"a" : " s0", "b" : "\t\ts1\n"} } } }"#,
),
FileWithContent(
"nested_trimmed.json",
r#"{ "l0" : {"l1": {"l2" : {"a" : "s0", "b" : "s1"} } } }"#,
),
]);
let actual = nu!(
cwd: dirs.test(), pipeline(
r#"
open nested.json
| trim
"#
));
let expected = nu!(
cwd: dirs.test(), pipeline(
r#"
open nested_trimmed.json
"#
));
assert_eq!(actual.out, expected.out)
})
}

View File

@ -7,7 +7,7 @@ use nu_test_support::pipeline;
fn filters_by_unit_size_comparison() {
let actual = nu!(
cwd: "tests/fixtures/formats",
"ls | where size > 1kb | sort-by size | get name | first 1 | trim | echo $it"
"ls | where size > 1kb | sort-by size | get name | first 1 | str trim | echo $it"
);
assert_eq!(actual.out, "cargo_sample.toml");