String interpolation (#1849)

* Add string interpolation

* fix coloring

* A few more fixups + tests

* merge master again
This commit is contained in:
Jonathan Turner
2020-05-19 12:27:26 -07:00
committed by GitHub
parent ae87582cb6
commit ed80933806
6 changed files with 303 additions and 13 deletions

View File

@ -100,6 +100,66 @@ fn invocation_handles_dot() {
})
}
#[test]
fn string_interpolation_with_it() {
let actual = nu!(
cwd: ".",
r#"
echo "foo" | echo `{{$it}}`
"#
);
assert_eq!(actual.out, "foo");
}
#[test]
fn string_interpolation_with_column() {
let actual = nu!(
cwd: ".",
r#"
echo '{"name": "bob"}' | from json | echo `{{name}} is cool`
"#
);
assert_eq!(actual.out, "bob is cool");
}
#[test]
fn string_interpolation_with_column2() {
let actual = nu!(
cwd: ".",
r#"
echo '{"name": "fred"}' | from json | echo `also {{name}} is cool`
"#
);
assert_eq!(actual.out, "also fred is cool");
}
#[test]
fn string_interpolation_with_column3() {
let actual = nu!(
cwd: ".",
r#"
echo '{"name": "sally"}' | from json | echo `also {{name}}`
"#
);
assert_eq!(actual.out, "also sally");
}
#[test]
fn string_interpolation_with_it_column_path() {
let actual = nu!(
cwd: ".",
r#"
echo '{"name": "sammie"}' | from json | echo `{{$it.name}}`
"#
);
assert_eq!(actual.out, "sammie");
}
#[test]
fn argument_invocation_reports_errors() {
let actual = nu!(