2020-07-14 17:04:00 +02:00
|
|
|
use nu_test_support::{nu, pipeline};
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn condition_is_met() {
|
2023-11-29 23:21:34 +01:00
|
|
|
let sample = r#"
|
|
|
|
[["Chicken Collection", "29/04/2020", "30/04/2020", "31/04/2020"];
|
|
|
|
["Yellow Chickens", "", "", ""],
|
|
|
|
[Andrés, 0, 0, 1],
|
|
|
|
[JT, 0, 0, 1],
|
|
|
|
[Jason, 0, 0, 1],
|
|
|
|
[Yehuda, 0, 0, 1],
|
|
|
|
["Blue Chickens", "", "", ""],
|
|
|
|
[Andrés, 0, 0, 2],
|
|
|
|
[JT, 0, 0, 2],
|
|
|
|
[Jason, 0, 0, 2],
|
|
|
|
[Yehuda, 0, 0, 2],
|
|
|
|
["Red Chickens", "", "", ""],
|
|
|
|
[Andrés, 0, 0, 1],
|
|
|
|
[JT, 0, 0, 1],
|
|
|
|
[Jason, 0, 0, 1],
|
|
|
|
[Yehuda, 0, 0, 3]]
|
|
|
|
"#;
|
2020-07-14 17:04:00 +02:00
|
|
|
|
2023-11-29 23:21:34 +01:00
|
|
|
let actual = nu!(pipeline(&format!(
|
|
|
|
r#"
|
|
|
|
{sample}
|
|
|
|
| skip until {{|row| $row."Chicken Collection" == "Red Chickens" }}
|
2022-02-04 03:01:45 +01:00
|
|
|
| skip 1
|
|
|
|
| into int "31/04/2020"
|
2020-07-14 17:04:00 +02:00
|
|
|
| get "31/04/2020"
|
|
|
|
| math sum
|
|
|
|
"#
|
2023-11-29 23:21:34 +01:00
|
|
|
)));
|
2020-07-14 17:04:00 +02:00
|
|
|
|
2023-11-29 23:21:34 +01:00
|
|
|
assert_eq!(actual.out, "6");
|
2020-07-14 17:04:00 +02:00
|
|
|
}
|
last, skip, drop, take until, take while, skip until, skip while, where, reverse, shuffle, append, prepend and sort-by raise error when given non-lists (#7623)
Closes https://github.com/nushell/nushell/issues/6941
2022-12-31 12:35:12 +01:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn fail_on_non_iterator() {
|
2023-07-17 18:43:51 +02:00
|
|
|
let actual = nu!("1 | skip until {|row| $row == 2}");
|
last, skip, drop, take until, take while, skip until, skip while, where, reverse, shuffle, append, prepend and sort-by raise error when given non-lists (#7623)
Closes https://github.com/nushell/nushell/issues/6941
2022-12-31 12:35:12 +01:00
|
|
|
|
2023-07-14 05:20:35 +02:00
|
|
|
assert!(actual.err.contains("command doesn't support"));
|
last, skip, drop, take until, take while, skip until, skip while, where, reverse, shuffle, append, prepend and sort-by raise error when given non-lists (#7623)
Closes https://github.com/nushell/nushell/issues/6941
2022-12-31 12:35:12 +01:00
|
|
|
}
|