2019-12-17 19:54:39 +01:00
|
|
|
use nu_test_support::{nu, pipeline};
|
2019-12-15 17:15:06 +01:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn insert_plugin() {
|
|
|
|
let actual = nu!(
|
|
|
|
cwd: "tests/fixtures/formats", pipeline(
|
|
|
|
r#"
|
|
|
|
open cargo_sample.toml
|
|
|
|
| insert dev-dependencies.newdep "1"
|
|
|
|
| get dev-dependencies.newdep
|
|
|
|
| echo $it
|
|
|
|
"#
|
|
|
|
));
|
|
|
|
|
2020-05-07 13:03:43 +02:00
|
|
|
assert_eq!(actual.out, "1");
|
2019-12-15 17:15:06 +01:00
|
|
|
}
|
2020-07-30 06:58:54 +02:00
|
|
|
|
|
|
|
#[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");
|
|
|
|
}
|