nushell/crates/nu-protocol/tests/test_value.rs

37 lines
932 B
Rust
Raw Normal View History

use nu_protocol::{Span, Value};
#[test]
fn test_comparison_nothing() {
let values = vec![
Value::test_int(1),
Value::test_string("string"),
Value::test_float(1.0),
];
let nothing = Value::Nothing {
span: Span::test_data(),
};
for value in values {
assert!(matches!(
value.eq(Span::test_data(), &nothing, Span::test_data()),
Ok(Value::Bool { val: false, .. })
));
assert!(matches!(
value.ne(Span::test_data(), &nothing, Span::test_data()),
Ok(Value::Bool { val: true, .. })
));
assert!(matches!(
nothing.eq(Span::test_data(), &value, Span::test_data()),
Ok(Value::Bool { val: false, .. })
));
assert!(matches!(
nothing.ne(Span::test_data(), &value, Span::test_data()),
Ok(Value::Bool { val: true, .. })
));
}
}