forked from extern/nushell
Make $nothing | into string == "" (#5490)
* Make $nothing | into string == "" * Fix up existing into string tests * Add $nothing | into string test * Formatting * Windows line endings test fix
This commit is contained in:
parent
94a9380e8b
commit
5f39267a80
@ -248,7 +248,7 @@ pub fn action(
|
||||
span,
|
||||
},
|
||||
Value::Nothing { .. } => Value::String {
|
||||
val: "nothing".to_string(),
|
||||
val: "".to_string(),
|
||||
span,
|
||||
},
|
||||
Value::Record {
|
||||
|
@ -1,4 +1,5 @@
|
||||
use nu_test_support::playground::{Dirs, Playground};
|
||||
use nu_test_support::fs::Stub::FileWithContentToBeTrimmed;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
@ -6,7 +7,7 @@ fn from_range() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 1..5 | into string | to json
|
||||
echo 1..5 | into string | to json -r
|
||||
"#
|
||||
)
|
||||
);
|
||||
@ -79,7 +80,7 @@ fn from_filename() {
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"ls sample.toml | get name | into string"
|
||||
"ls sample.toml | get name | into string | get 0"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "sample.toml");
|
||||
@ -99,10 +100,12 @@ fn from_filesize() {
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"ls sample.toml | get size | into string"
|
||||
"ls sample.toml | get size | into string | get 0"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "25 B");
|
||||
let expected = if cfg!(windows) { "27 B" } else { "25 B" };
|
||||
|
||||
assert_eq!(actual.out, expected);
|
||||
})
|
||||
}
|
||||
|
||||
@ -111,7 +114,7 @@ fn from_decimal_correct_trailing_zeros() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
= 1.23000 | into string -d 3
|
||||
1.23000 | into string -d 3
|
||||
"#
|
||||
));
|
||||
|
||||
@ -123,7 +126,7 @@ fn from_int_decimal_correct_trailing_zeros() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
= 1.00000 | into string -d 3
|
||||
1.00000 | into string -d 3
|
||||
"#
|
||||
));
|
||||
|
||||
@ -135,7 +138,7 @@ fn from_int_decimal_trim_trailing_zeros() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
= 1.00000 | into string | format "{$it} flat"
|
||||
1.00000 | into string | $"($in) flat"
|
||||
"#
|
||||
));
|
||||
|
||||
@ -156,3 +159,15 @@ fn from_table() {
|
||||
assert!(actual.out.contains("32.38"));
|
||||
assert!(actual.out.contains("15.20"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_nothing() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
$nothing | into string
|
||||
"#
|
||||
));
|
||||
|
||||
assert_eq!(actual.out, "");
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
mod collect;
|
||||
mod into_string;
|
||||
|
||||
use nu_test_support::fs::Stub::FileWithContent;
|
||||
use nu_test_support::playground::Playground;
|
||||
|
Loading…
Reference in New Issue
Block a user