2021-12-20 01:05:33 +00:00
|
|
|
use nu_protocol::{Span, Value};
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_comparison_nothing() {
|
|
|
|
let values = vec![
|
2022-12-24 13:41:57 +00:00
|
|
|
Value::test_int(1),
|
2022-12-24 09:25:38 +00:00
|
|
|
Value::test_string("string"),
|
2022-12-24 13:41:57 +00:00
|
|
|
Value::test_float(1.0),
|
2021-12-20 01:05:33 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
let nothing = Value::Nothing {
|
|
|
|
span: Span::test_data(),
|
|
|
|
};
|
|
|
|
|
|
|
|
for value in values {
|
|
|
|
assert!(matches!(
|
2022-04-09 05:17:48 +00:00
|
|
|
value.eq(Span::test_data(), ¬hing, Span::test_data()),
|
2021-12-20 01:05:33 +00:00
|
|
|
Ok(Value::Bool { val: false, .. })
|
|
|
|
));
|
|
|
|
|
|
|
|
assert!(matches!(
|
2022-04-09 05:17:48 +00:00
|
|
|
value.ne(Span::test_data(), ¬hing, Span::test_data()),
|
2021-12-20 01:05:33 +00:00
|
|
|
Ok(Value::Bool { val: true, .. })
|
|
|
|
));
|
|
|
|
|
|
|
|
assert!(matches!(
|
2022-04-09 05:17:48 +00:00
|
|
|
nothing.eq(Span::test_data(), &value, Span::test_data()),
|
2021-12-20 01:05:33 +00:00
|
|
|
Ok(Value::Bool { val: false, .. })
|
|
|
|
));
|
|
|
|
|
|
|
|
assert!(matches!(
|
2022-04-09 05:17:48 +00:00
|
|
|
nothing.ne(Span::test_data(), &value, Span::test_data()),
|
2021-12-20 01:05:33 +00:00
|
|
|
Ok(Value::Bool { val: true, .. })
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|