mirror of
https://github.com/nushell/nushell.git
synced 2024-11-26 18:33:50 +01:00
e949658381
* nothing variable * corrected comments * added color to nothing like bool * compare nothing with values * comparison tests
46 lines
1.0 KiB
Rust
46 lines
1.0 KiB
Rust
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!(
|
|
value.eq(Span::test_data(), ¬hing),
|
|
Ok(Value::Bool { val: false, .. })
|
|
));
|
|
|
|
assert!(matches!(
|
|
value.ne(Span::test_data(), ¬hing),
|
|
Ok(Value::Bool { val: true, .. })
|
|
));
|
|
|
|
assert!(matches!(
|
|
nothing.eq(Span::test_data(), &value),
|
|
Ok(Value::Bool { val: false, .. })
|
|
));
|
|
|
|
assert!(matches!(
|
|
nothing.ne(Span::test_data(), &value),
|
|
Ok(Value::Bool { val: true, .. })
|
|
));
|
|
}
|
|
}
|