Apply continue to each (#8889)

# Description
Fixes #8878
Add continue command on each and added new tests too .
This commit is contained in:
Amirhossein Akhlaghpour
2023-04-15 08:41:02 +03:30
committed by GitHub
parent 45d33e70db
commit fff4de5c44
2 changed files with 19 additions and 0 deletions

View File

@ -73,3 +73,19 @@ fn each_while_uses_enumerate_index() {
assert_eq!(actual.out, "[0, 1, 2, 3]");
}
#[test]
fn each_element_continue_command() {
let actual =
nu!("[1,2,3,4,6,7] | each { |x| if ($x mod 2 == 0) {continue} else { $x }} | to nuon");
assert_eq!(actual.out, "[1, 3, 7]");
}
#[test]
fn each_element_break_command() {
let actual =
nu!("[1,2,5,4,6,7] | each { |x| if ($x mod 3 == 0) {break} else { $x }} | to nuon");
assert_eq!(actual.out, "[1, 2, 5, 4]");
}