From 0bf2e7a9e84c447a48f13fb65649ed930910490a Mon Sep 17 00:00:00 2001 From: Devyn Cairns Date: Tue, 23 Jul 2024 02:08:31 -0700 Subject: [PATCH] add more tests for new behavior --- crates/nu-command/tests/commands/let_.rs | 7 +++++++ tests/const_/mod.rs | 6 ++++++ tests/repl/test_parser.rs | 16 ++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/crates/nu-command/tests/commands/let_.rs b/crates/nu-command/tests/commands/let_.rs index 7e0273ebd8..e05d34d258 100644 --- a/crates/nu-command/tests/commands/let_.rs +++ b/crates/nu-command/tests/commands/let_.rs @@ -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 = [] | append "hello world"; print $x.0"#); + + assert_eq!(actual.out, "hello world"); +} + #[test] fn mut_pipeline_allows_in() { let actual = diff --git a/tests/const_/mod.rs b/tests/const_/mod.rs index 04db29d3dd..f736b785ca 100644 --- a/tests/const_/mod.rs +++ b/tests/const_/mod.rs @@ -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"); +} diff --git a/tests/repl/test_parser.rs b/tests/repl/test_parser.rs index a7a25e1c67..ea983ff82c 100644 --- a/tests/repl/test_parser.rs +++ b/tests/repl/test_parser.rs @@ -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#"$"('(')(')')""#, "()")