Add in parameter inference for blocks (#2706)

This commit is contained in:
Jonathan Turner
2020-10-27 20:37:35 +13:00
committed by GitHub
parent c283db373b
commit ee76523507
9 changed files with 150 additions and 69 deletions

View File

@@ -47,3 +47,27 @@ fn each_window_stride() {
assert_eq!(actual.out, "[[1,2,3],[3,4,5]]");
}
#[test]
fn each_no_args_in_block() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
echo [[foo bar]; [a b] [c d] [e f]] | each { to json } | nth 1 | str collect
"#
));
assert_eq!(actual.out, r#"{"foo":"c","bar":"d"}"#);
}
#[test]
fn each_implicit_it_in_block() {
let actual = nu!(
cwd: "tests/fixtures/formats", pipeline(
r#"
echo [[foo bar]; [a b] [c d] [e f]] | each { nu --testbin cococo $it.foo }
"#
));
assert_eq!(actual.out, "ace");
}