-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
crates/nu-command/tests/commands/assignment/append_assign.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
use nu_test_support::{nu, pipeline}; | ||
|
||
#[test] | ||
fn append_assign_int() { | ||
let actual = nu!( | ||
cwd: ".", pipeline( | ||
r#" | ||
mut a = [1 2]; | ||
$a ++= [3 4]; | ||
$a | ||
"# | ||
)); | ||
|
||
let expected = nu!( | ||
cwd: ".", pipeline( | ||
r#" | ||
[1 2 3 4] | ||
"# | ||
)); | ||
|
||
print!("{}", actual.out); | ||
print!("{}", expected.out); | ||
assert_eq!(actual.out, expected.out); | ||
} | ||
|
||
#[test] | ||
fn append_assign_string() { | ||
let actual = nu!( | ||
cwd: ".", pipeline( | ||
r#" | ||
mut a = [a b]; | ||
$a ++= [c d]; | ||
$a | ||
"# | ||
)); | ||
|
||
let expected = nu!( | ||
cwd: ".", pipeline( | ||
r#" | ||
[a b c d] | ||
"# | ||
)); | ||
|
||
print!("{}", actual.out); | ||
print!("{}", expected.out); | ||
assert_eq!(actual.out, expected.out); | ||
} | ||
|
||
#[test] | ||
fn append_assign_any() { | ||
let actual = nu!( | ||
cwd: ".", pipeline( | ||
r#" | ||
mut a = [1 2 a]; | ||
$a ++= [b 3]; | ||
$a | ||
"# | ||
)); | ||
|
||
let expected = nu!( | ||
cwd: ".", pipeline( | ||
r#" | ||
[1 2 a b 3] | ||
"# | ||
)); | ||
|
||
print!("{}", actual.out); | ||
print!("{}", expected.out); | ||
assert_eq!(actual.out, expected.out); | ||
} | ||
|
||
#[test] | ||
fn append_assign_both_empty() { | ||
let actual = nu!( | ||
cwd: ".", pipeline( | ||
r#" | ||
mut a = []; | ||
$a ++= []; | ||
$a | ||
"# | ||
)); | ||
|
||
let expected = nu!( | ||
cwd: ".", pipeline( | ||
r#" | ||
[] | ||
"# | ||
)); | ||
|
||
print!("{}", actual.out); | ||
print!("{}", expected.out); | ||
assert_eq!(actual.out, expected.out); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
mod append_assign; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ mod alias; | |
mod all; | ||
mod any; | ||
mod append; | ||
mod assignment; | ||
mod break_; | ||
mod cal; | ||
mod cd; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters