mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 06:08:51 +02:00
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:
@ -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!(
|
||||
|
Reference in New Issue
Block a user