rhai/tests/throw.rs

17 lines
425 B
Rust
Raw Normal View History

2020-03-14 16:40:30 +01:00
use rhai::{Engine, EvalAltResult};
2020-03-03 11:15:20 +01:00
#[test]
fn test_throw() {
let engine = Engine::new();
2020-03-03 11:15:20 +01:00
2020-03-14 16:40:30 +01:00
assert!(matches!(
*engine.eval::<()>(r#"if true { throw "hello" }"#).expect_err("expects error"),
EvalAltResult::ErrorRuntime(s, _) if s == "hello"
));
2020-03-03 11:15:20 +01:00
2020-03-14 16:40:30 +01:00
assert!(matches!(
*engine.eval::<()>(r#"throw"#).expect_err("expects error"),
EvalAltResult::ErrorRuntime(s, _) if s == ""
));
2020-03-03 11:15:20 +01:00
}