Make insert take in a block (#2265)

* Make insert take in a block

* Add some tests
This commit is contained in:
Shaurya Shubham
2020-07-30 10:28:54 +05:30
committed by GitHub
parent 878b748a41
commit 3282a509a9
3 changed files with 125 additions and 18 deletions

View File

@ -14,3 +14,27 @@ fn insert_plugin() {
assert_eq!(actual.out, "1");
}
#[test]
fn downcase_upcase() {
let actual = nu!(
cwd: ".", pipeline(
r#"
echo abcd | wrap downcase | insert upcase { echo $it.downcase | str upcase } | format "{downcase}{upcase}"
"#
));
assert_eq!(actual.out, "abcdABCD");
}
#[test]
fn number_and_its_negative_equal_zero() {
let actual = nu!(
cwd: ".", pipeline(
r#"
echo 1..10 | wrap num | insert neg { = $it.num * -1 } | math sum | = $it.num + $it.neg
"#
));
assert_eq!(actual.out, "0");
}