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