forked from extern/nushell
Make ++ operator work with strings and binary values (#8017)
This PR makes `++` (the append operator) work with strings and binary values. Can now do things like: ```bash 〉"a" ++ "b" ab 〉0x[01 02] ++ 0x[03] Length: 3 (0x3) bytes | printable whitespace ascii_other non_ascii 00000000: 01 02 03 ••• ``` Closes #8015.
This commit is contained in:
@ -473,6 +473,8 @@ fn compound_where_paren() {
|
||||
assert_eq!(actual.out, r#"[{"a": 2,"b": 1},{"a": 2,"b": 2}]"#);
|
||||
}
|
||||
|
||||
// TODO: these ++ tests are not really testing *math* functionality, maybe find another place for them
|
||||
|
||||
#[test]
|
||||
fn adding_lists() {
|
||||
let actual = nu!(
|
||||
@ -519,3 +521,25 @@ fn adding_tables() {
|
||||
));
|
||||
assert_eq!(actual.out, "[{a: 1, b: 2}, {c: 10, d: 11}]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn append_strings() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
"foo" ++ "bar"
|
||||
"#
|
||||
));
|
||||
assert_eq!(actual.out, "foobar");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn append_binary_values() {
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
r#"
|
||||
0x[01 02] ++ 0x[03 04] | to nuon
|
||||
"#
|
||||
));
|
||||
assert_eq!(actual.out, "0x[01020304]");
|
||||
}
|
||||
|
Reference in New Issue
Block a user