mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 12:55:47 +02:00
Remove old nushell/merge engine-q
This commit is contained in:
@ -44,18 +44,10 @@ fn sum_one_to_four() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo 1..4 | into string | str collect "+" | math eval
|
||||
=======
|
||||
1..4 | each { $it } | into string | str collect "+" | math eval
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
<<<<<<< HEAD
|
||||
assert!(actual.out.contains("10.0"));
|
||||
=======
|
||||
assert!(actual.out.contains("10"));
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
}
|
||||
|
158
crates/nu-command/tests/commands/str_/into_string.rs
Normal file
158
crates/nu-command/tests/commands/str_/into_string.rs
Normal file
@ -0,0 +1,158 @@
|
||||
use nu_test_support::playground::{Dirs, Playground};
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
#[test]
|
||||
fn from_range() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 1..5 | into string | to json
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "[\"1\",\"2\",\"3\",\"4\",\"5\"]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_number() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 5 | into string
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "5");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_decimal() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo 1.5 | into string
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "1.5");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_boolean() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo $true | into string
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "true");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_string() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo "one" | into string
|
||||
"#
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "one");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_filename() {
|
||||
Playground::setup("from_filename", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[dependency]
|
||||
name = "nu"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"ls sample.toml | get name | into string"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "sample.toml");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_filesize() {
|
||||
Playground::setup("from_filesize", |dirs, sandbox| {
|
||||
sandbox.with_files(vec![FileWithContentToBeTrimmed(
|
||||
"sample.toml",
|
||||
r#"
|
||||
[dependency]
|
||||
name = "nu"
|
||||
"#,
|
||||
)]);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test(),
|
||||
"ls sample.toml | get size | into string"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "25 B");
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_decimal_correct_trailing_zeros() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
= 1.23000 | into string -d 3
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("1.230"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_int_decimal_correct_trailing_zeros() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
= 1.00000 | into string -d 3
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("1.000"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_int_decimal_trim_trailing_zeros() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
= 1.00000 | into string | format "{$it} flat"
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("1 flat")); // "1" would match "1.0"
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_table() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
echo '[{"name": "foo", "weight": 32.377}, {"name": "bar", "weight": 15.2}]'
|
||||
| from json
|
||||
| into string weight -d 2
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual.out.contains("32.38"));
|
||||
assert!(actual.out.contains("15.20"));
|
||||
}
|
@ -29,11 +29,7 @@ fn error_trim_multiple_chars() {
|
||||
let actual = nu!(
|
||||
cwd: ".", pipeline(
|
||||
r#"
|
||||
<<<<<<< HEAD
|
||||
echo 'does it work now?!' | str trim -c '?!'
|
||||
=======
|
||||
echo "does it work now?!" | str trim -c "?!"
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
"#
|
||||
)
|
||||
);
|
||||
@ -128,11 +124,7 @@ fn converts_to_int() {
|
||||
r#"
|
||||
echo '{number_as_string: "1"}'
|
||||
| from json
|
||||
<<<<<<< HEAD
|
||||
| str to-int number_as_string
|
||||
=======
|
||||
| into int number_as_string
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| rename number
|
||||
| where number == 1
|
||||
| get number
|
||||
@ -150,11 +142,7 @@ fn converts_to_decimal() {
|
||||
r#"
|
||||
echo "3.1, 0.0415"
|
||||
| split row ","
|
||||
<<<<<<< HEAD
|
||||
| str to-decimal
|
||||
=======
|
||||
| into decimal
|
||||
>>>>>>> 9259a56a28f1dd3a4b720ad815aa19c6eaf6adce
|
||||
| math sum
|
||||
"#
|
||||
));
|
||||
|
Reference in New Issue
Block a user