mirror of
https://github.com/nushell/nushell
synced 2025-01-14 06:04:09 +00:00
Fix nothing string comparison (#3750)
This commit is contained in:
parent
720217a5e4
commit
69fa040361
2 changed files with 28 additions and 0 deletions
|
@ -164,6 +164,10 @@ pub fn coerce_compare_primitive(
|
||||||
(Boolean(left), Boolean(right)) => CompareValues::Booleans(*left, *right),
|
(Boolean(left), Boolean(right)) => CompareValues::Booleans(*left, *right),
|
||||||
(Boolean(left), Nothing) => CompareValues::Booleans(*left, false),
|
(Boolean(left), Nothing) => CompareValues::Booleans(*left, false),
|
||||||
(Nothing, Boolean(right)) => CompareValues::Booleans(false, *right),
|
(Nothing, Boolean(right)) => CompareValues::Booleans(false, *right),
|
||||||
|
(String(left), Nothing) => CompareValues::String(left.clone(), std::string::String::new()),
|
||||||
|
(Nothing, String(right)) => {
|
||||||
|
CompareValues::String(std::string::String::new(), right.clone())
|
||||||
|
}
|
||||||
(FilePath(left), String(right)) => {
|
(FilePath(left), String(right)) => {
|
||||||
CompareValues::String(left.as_path().display().to_string(), right.clone())
|
CompareValues::String(left.as_path().display().to_string(), right.clone())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1083,6 +1083,30 @@ fn manysubcommand() {
|
||||||
assert_eq!(actual.out, "localhost loaded");
|
assert_eq!(actual.out, "localhost loaded");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn nothing_string_1() {
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: ".", pipeline(
|
||||||
|
r#"
|
||||||
|
$nothing == "foo"
|
||||||
|
"#)
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(actual.out, "false");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn nothing_string_2() {
|
||||||
|
let actual = nu!(
|
||||||
|
cwd: ".", pipeline(
|
||||||
|
r#"
|
||||||
|
"" == $nothing
|
||||||
|
"#)
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(actual.out, "true");
|
||||||
|
}
|
||||||
|
|
||||||
mod parse {
|
mod parse {
|
||||||
use nu_test_support::nu;
|
use nu_test_support::nu;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue