add more tests for new behavior

This commit is contained in:
Devyn Cairns 2024-07-23 02:08:31 -07:00
parent e81d2860ef
commit 0bf2e7a9e8
No known key found for this signature in database
3 changed files with 29 additions and 0 deletions

View File

@ -45,6 +45,13 @@ fn mut_takes_pipeline() {
assert_eq!(actual.out, "11");
}
#[test]
fn mut_takes_pipeline_with_declared_type() {
let actual = nu!(r#"mut x: list<string> = [] | append "hello world"; print $x.0"#);
assert_eq!(actual.out, "hello world");
}
#[test]
fn mut_pipeline_allows_in() {
let actual =

View File

@ -415,3 +415,9 @@ fn const_raw_string() {
let actual = nu!(r#"const x = r#'abc'#; $x"#);
assert_eq!(actual.out, "abc");
}
#[test]
fn const_takes_pipeline() {
let actual = nu!(r#"const list = 'bar_baz_quux' | split row '_'; $list | length"#);
assert_eq!(actual.out, "3");
}

View File

@ -295,6 +295,22 @@ fn assign_expressions() -> TestResult {
)
}
#[test]
fn assign_takes_pipeline() -> TestResult {
run_test(
r#"mut foo = 'bar'; $foo = $foo | str upcase | str reverse; $foo"#,
"RAB",
)
}
#[test]
fn append_assign_takes_pipeline() -> TestResult {
run_test(
r#"mut foo = 'bar'; $foo ++= $foo | str upcase; $foo"#,
"barBAR",
)
}
#[test]
fn string_interpolation_paren_test() -> TestResult {
run_test(r#"$"('(')(')')""#, "()")