rhai/tests/unary_after_binary.rs
2020-03-10 23:06:20 +08:00

18 lines
576 B
Rust

use rhai::{Engine, EvalAltResult, INT};
#[test]
// TODO also add test case for unary after compound
// Hah, turns out unary + has a good use after all!
fn test_unary_after_binary() -> Result<(), EvalAltResult> {
let mut engine = Engine::new();
assert_eq!(engine.eval::<INT>("10 % +4")?, 2);
assert_eq!(engine.eval::<INT>("10 << +4")?, 160);
assert_eq!(engine.eval::<INT>("10 >> +4")?, 0);
assert_eq!(engine.eval::<INT>("10 & +4")?, 0);
assert_eq!(engine.eval::<INT>("10 | +4")?, 14);
assert_eq!(engine.eval::<INT>("10 ^ +4")?, 14);
Ok(())
}