forked from extern/nushell
Signed-off-by: closetool <c299999999@qq.com>
This commit is contained in:
parent
ad94ed5e13
commit
9fd680ae2b
@ -164,8 +164,8 @@ pub fn coerce_compare_primitive(
|
||||
(Date(left), Date(right)) => CompareValues::Date(*left, *right),
|
||||
(Date(left), Duration(right)) => CompareValues::DateDuration(*left, right.clone()),
|
||||
(Boolean(left), Boolean(right)) => CompareValues::Booleans(*left, *right),
|
||||
(Boolean(left), Nothing) => CompareValues::Booleans(*left, false),
|
||||
(Nothing, Boolean(right)) => CompareValues::Booleans(false, *right),
|
||||
(Boolean(left), Nothing) => CompareValues::Ints(if *left { 1 } else { 0 }, -1),
|
||||
(Nothing, Boolean(right)) => CompareValues::Ints(-1, if *right { 1 } else { 0 }),
|
||||
(String(left), Nothing) => CompareValues::String(left.clone(), std::string::String::new()),
|
||||
(Nothing, String(right)) => {
|
||||
CompareValues::String(std::string::String::new(), right.clone())
|
||||
|
@ -34,3 +34,21 @@ fn compare_to_nothing() {
|
||||
);
|
||||
assert_eq!(actual.out, "true");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compare_nothing_and_boolean() {
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
if $true == $nothing {echo $true} {echo $false}
|
||||
"#
|
||||
);
|
||||
assert_eq!(actual.out, "false");
|
||||
let actual = nu!(
|
||||
cwd: ".",
|
||||
r#"
|
||||
if $false == $nothing {echo $true} {echo $false}
|
||||
"#
|
||||
);
|
||||
assert_eq!(actual.out, "false");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user