2021-12-20 02:05:33 +01:00
|
|
|
use nu_protocol::{Span, Value};
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_comparison_nothing() {
|
|
|
|
let values = vec![
|
|
|
|
Value::Int {
|
|
|
|
val: 1,
|
|
|
|
span: Span::test_data(),
|
|
|
|
},
|
|
|
|
Value::String {
|
|
|
|
val: "string".into(),
|
|
|
|
span: Span::test_data(),
|
|
|
|
},
|
|
|
|
Value::Float {
|
|
|
|
val: 1.0,
|
|
|
|
span: Span::test_data(),
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
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, .. })
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|