Allow iteration blocks to have an optional extra index parameter (alternative to -n flags) (#6994)

Alters `all`, `any`, `each while`, `each`, `insert`, `par-each`, `reduce`, `update`, `upsert` and `where`,
so that their blocks take an optional parameter containing the index.
This commit is contained in:
Leon
2022-11-21 23:35:11 +10:00
committed by GitHub
parent 899383c30c
commit 833825ae9a
19 changed files with 486 additions and 74 deletions

View File

@ -108,6 +108,16 @@ fn early_exits_with_0_param_blocks() {
assert_eq!(actual.out, "1false");
}
#[test]
fn uses_optional_index_argument() {
let actual = nu!(
cwd: ".", pipeline(
r#"[7 8 9] | all {|el ind| print $ind | true }"#
));
assert_eq!(actual.out, "012true");
}
#[test]
fn unique_env_each_iteration() {
let actual = nu!(