2020-04-30 06:18:24 +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, 1, 1, 1],
|
|
|
|
[JT, 1, 1, 1],
|
|
|
|
[Jason, 1, 1, 1],
|
|
|
|
[Yehuda, 1, 1, 1],
|
|
|
|
["Blue Chickens", "", "", ""],
|
|
|
|
[Andrés, 1, 1, 2],
|
|
|
|
[JT, 1, 1, 2],
|
|
|
|
[Jason, 1, 1, 2],
|
|
|
|
[Yehuda, 1, 1, 2],
|
|
|
|
["Red Chickens", "", "", ""],
|
|
|
|
[Andrés, 1, 1, 3],
|
|
|
|
[JT, 1, 1, 3],
|
|
|
|
[Jason, 1, 1, 3],
|
|
|
|
[Yehuda, 1, 1, 3]]
|
|
|
|
"#;
|
2020-04-30 06:18:24 +02:00
|
|
|
|
2023-11-29 23:21:34 +01:00
|
|
|
let actual = nu!(pipeline(&format!(
|
|
|
|
r#"
|
|
|
|
{sample}
|
2022-02-04 03:01:45 +01:00
|
|
|
| skip 1
|
2023-11-29 23:21:34 +01:00
|
|
|
| take while {{|row| $row."Chicken Collection" != "Blue Chickens"}}
|
2022-02-04 03:01:45 +01:00
|
|
|
| into int "31/04/2020"
|
2020-04-30 06:18:24 +02:00
|
|
|
| get "31/04/2020"
|
2020-06-19 04:02:01 +02:00
|
|
|
| math sum
|
2020-04-30 06:18:24 +02:00
|
|
|
"#
|
2023-11-29 23:21:34 +01:00
|
|
|
)));
|
2020-04-30 06:18:24 +02:00
|
|
|
|
2023-11-29 23:21:34 +01:00
|
|
|
assert_eq!(actual.out, "4");
|
2020-04-30 06:18:24 +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 | take while {|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
|
|
|
}
|