mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
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 commit959d14203e
. * 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)
This commit is contained in:
@ -12,7 +12,7 @@ fn bits_and_negative() -> TestResult {
|
||||
|
||||
#[test]
|
||||
fn bits_and_list() -> TestResult {
|
||||
run_test("[1 2 3 8 9 10] | bits and 2 | str collect '.'", "0.2.2.0.0.2")
|
||||
run_test("[1 2 3 8 9 10] | bits and 2 | str join '.'", "0.2.2.0.0.2")
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -27,7 +27,7 @@ fn bits_or_negative() -> TestResult {
|
||||
|
||||
#[test]
|
||||
fn bits_or_list() -> TestResult {
|
||||
run_test("[1 2 3 8 9 10] | bits or 2 | str collect '.'", "3.2.3.10.11.10")
|
||||
run_test("[1 2 3 8 9 10] | bits or 2 | str join '.'", "3.2.3.10.11.10")
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -42,7 +42,7 @@ fn bits_xor_negative() -> TestResult {
|
||||
|
||||
#[test]
|
||||
fn bits_xor_list() -> TestResult {
|
||||
run_test("[1 2 3 8 9 10] | bits xor 2 | str collect '.'", "3.0.1.10.11.8")
|
||||
run_test("[1 2 3 8 9 10] | bits xor 2 | str join '.'", "3.0.1.10.11.8")
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -57,7 +57,7 @@ fn bits_shift_left_negative() -> TestResult {
|
||||
|
||||
#[test]
|
||||
fn bits_shift_left_list() -> TestResult {
|
||||
run_test("[1 2 7 32 9 10] | bits shl 3 | str collect '.'", "8.16.56.256.72.80")
|
||||
run_test("[1 2 7 32 9 10] | bits shl 3 | str join '.'", "8.16.56.256.72.80")
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -72,7 +72,7 @@ fn bits_shift_right_negative() -> TestResult {
|
||||
|
||||
#[test]
|
||||
fn bits_shift_right_list() -> TestResult {
|
||||
run_test("[12 98 7 64 900 10] | bits shr 3 | str collect '.'", "1.12.0.8.112.1")
|
||||
run_test("[12 98 7 64 900 10] | bits shr 3 | str join '.'", "1.12.0.8.112.1")
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -87,7 +87,7 @@ fn bits_rotate_left_negative() -> TestResult {
|
||||
|
||||
#[test]
|
||||
fn bits_rotate_left_list() -> TestResult {
|
||||
run_test("[1 2 7 32 9 10] | bits rol 3 | str collect '.'", "8.16.56.256.72.80")
|
||||
run_test("[1 2 7 32 9 10] | bits rol 3 | str join '.'", "8.16.56.256.72.80")
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -102,5 +102,5 @@ fn bits_rotate_right_negative() -> TestResult {
|
||||
|
||||
#[test]
|
||||
fn bits_rotate_right_list() -> TestResult {
|
||||
run_test("[1 2 7 32 23 10] | bits ror 60 | str collect '.'", "16.32.112.512.368.160")
|
||||
run_test("[1 2 7 32 23 10] | bits ror 60 | str join '.'", "16.32.112.512.368.160")
|
||||
}
|
||||
|
@ -335,7 +335,7 @@ fn in_means_input() -> TestResult {
|
||||
#[test]
|
||||
fn in_iteration() -> TestResult {
|
||||
run_test(
|
||||
r#"[3, 4, 5] | each { echo $"hi ($in)" } | str collect"#,
|
||||
r#"[3, 4, 5] | each { echo $"hi ($in)" } | str join"#,
|
||||
"hi 3hi 4hi 5",
|
||||
)
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ def 'call-me' [] {
|
||||
echo $CONST_A
|
||||
}
|
||||
|
||||
[(say-hi) (call-me)] | str collect
|
||||
[(say-hi) (call-me)] | str join
|
||||
|
||||
"#,
|
||||
"HelloHello",
|
||||
@ -266,7 +266,7 @@ def 'say-hi' [] {
|
||||
echo (call-me)
|
||||
}
|
||||
|
||||
[(say-hi) (call-me)] | str collect
|
||||
[(say-hi) (call-me)] | str join
|
||||
|
||||
"#,
|
||||
"HelloHello",
|
||||
@ -287,7 +287,7 @@ def 'call-me' [] {
|
||||
echo $CONST_A
|
||||
}
|
||||
|
||||
[(call-me) (say-hi)] | str collect
|
||||
[(call-me) (say-hi)] | str join
|
||||
|
||||
"#,
|
||||
"HelloHello",
|
||||
@ -308,7 +308,7 @@ def 'say-hi' [] {
|
||||
echo (call-me)
|
||||
}
|
||||
|
||||
[(call-me) (say-hi)] | str collect
|
||||
[(call-me) (say-hi)] | str join
|
||||
|
||||
"#,
|
||||
"HelloHello",
|
||||
@ -318,7 +318,7 @@ def 'say-hi' [] {
|
||||
#[test]
|
||||
fn capture_row_condition() -> TestResult {
|
||||
run_test(
|
||||
r#"let name = "foo"; [foo] | where $'($name)' =~ $it | str collect"#,
|
||||
r#"let name = "foo"; [foo] | where $'($name)' =~ $it | str join"#,
|
||||
"foo",
|
||||
)
|
||||
}
|
||||
@ -326,7 +326,7 @@ fn capture_row_condition() -> TestResult {
|
||||
#[test]
|
||||
fn starts_with_operator_succeeds() -> TestResult {
|
||||
run_test(
|
||||
r#"[Moe Larry Curly] | where $it starts-with L | str collect"#,
|
||||
r#"[Moe Larry Curly] | where $it starts-with L | str join"#,
|
||||
"Larry",
|
||||
)
|
||||
}
|
||||
@ -334,7 +334,7 @@ fn starts_with_operator_succeeds() -> TestResult {
|
||||
#[test]
|
||||
fn ends_with_operator_succeeds() -> TestResult {
|
||||
run_test(
|
||||
r#"[Moe Larry Curly] | where $it ends-with ly | str collect"#,
|
||||
r#"[Moe Larry Curly] | where $it ends-with ly | str join"#,
|
||||
"Curly",
|
||||
)
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ fn cell_path_var2() -> TestResult {
|
||||
#[test]
|
||||
fn flatten_simple_list() -> TestResult {
|
||||
run_test(
|
||||
"[[N, u, s, h, e, l, l]] | flatten | str collect (char nl)",
|
||||
"[[N, u, s, h, e, l, l]] | flatten | str join (char nl)",
|
||||
"N\nu\ns\nh\ne\nl\nl",
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user