Another batch of command tests (#4496)

* Add a batch of command tests

* More tests
This commit is contained in:
JT
2022-02-16 07:38:02 -05:00
committed by GitHub
parent 644435bfe3
commit c4e1559f89
13 changed files with 43 additions and 70 deletions

View File

@ -1,7 +1,5 @@
use nu_test_support::{nu, pipeline};
// FIXME: jt: needs more work
#[ignore]
#[test]
fn reduce_table_column() {
let actual = nu!(
@ -10,7 +8,7 @@ fn reduce_table_column() {
echo "[{month:2,total:30}, {month:3,total:10}, {month:4,total:3}, {month:5,total:60}]"
| from json
| get total
| reduce -f 20 { $it.item + (math eval $"($item.acc)^1.05")}
| reduce -f 20 { $it.item + (math eval $"($it.acc)^1.05")}
| into string -d 1
"#
)
@ -19,15 +17,13 @@ fn reduce_table_column() {
assert_eq!(actual.out, "180.6");
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn reduce_table_column_with_path() {
let actual = nu!(
cwd: ".", pipeline(
r#"
[{month:2,total:30}, {month:3,total:10}, {month:4,total:3}, {month:5,total:60}]
| reduce -f 20 { $it.item.total + (math eval $"($item.acc)^1.05")}
| reduce -f 20 { $it.item.total + (math eval $"($it.acc)^1.05")}
| into string -d 1
"#
)
@ -36,8 +32,6 @@ fn reduce_table_column_with_path() {
assert_eq!(actual.out, "180.6");
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn reduce_rows_example() {
let actual = nu!(
@ -60,7 +54,7 @@ fn reduce_numbered_example() {
cwd: ".", pipeline(
r#"
echo one longest three bar
| reduce -n { if ($it.item.item | str length) > ($it.acc.item | str length) {echo $it.item} else {echo $it.acc}}
reduce -n { if ($it.item | str length) > ($acc.item | str length) {echo $it} {echo $acc}}
| get index
"#
)
@ -69,15 +63,13 @@ fn reduce_numbered_example() {
assert_eq!(actual.out, "1");
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn reduce_numbered_integer_addition_example() {
let actual = nu!(
cwd: ".", pipeline(
r#"
echo [1 2 3 4]
| reduce -n { $it.acc.item + $it.item.item }
| reduce -n { $it.acc + $it.item }
| get item
"#
)
@ -86,8 +78,6 @@ fn reduce_numbered_integer_addition_example() {
assert_eq!(actual.out, "10");
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn folding_with_tables() {
let actual = nu!(
@ -96,7 +86,7 @@ fn folding_with_tables() {
echo [10 20 30 40]
| reduce -f [] {
with-env [value $it.item] {
echo $acc | append (10 * ($env.value | into int))
echo $it.acc | append (10 * ($env.value | into int))
}
}
| math sum
@ -107,8 +97,6 @@ fn folding_with_tables() {
assert_eq!(actual.out, "1000");
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn error_reduce_fold_type_mismatch() {
let actual = nu!(
@ -122,8 +110,6 @@ fn error_reduce_fold_type_mismatch() {
assert!(actual.err.contains("mismatch"));
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn error_reduce_empty() {
let actual = nu!(