rhai/tests/not.rs

22 lines
474 B
Rust
Raw Normal View History

use rhai::Engine;
2017-11-03 17:58:51 +01:00
#[test]
fn test_not() {
2019-09-18 12:21:07 +02:00
let mut engine = Engine::new();
2017-11-03 17:58:51 +01:00
2019-09-18 12:21:07 +02:00
assert_eq!(
engine
.eval::<bool>("let not_true = !true; not_true")
.unwrap(),
false
);
2017-11-03 17:58:51 +01:00
2019-09-18 12:21:07 +02:00
assert_eq!(
engine.eval::<bool>("fn not(x) { !x } not(false)").unwrap(),
true
);
2017-11-03 17:58:51 +01:00
2019-09-18 12:21:07 +02:00
// TODO - do we allow stacking unary operators directly? e.g '!!!!!!!true'
assert_eq!(engine.eval::<bool>("!(!(!(!(true))))").unwrap(), true)
2017-11-03 17:58:51 +01:00
}