rhai/tests/throw.rs
2020-03-18 10:42:27 +08:00

15 lines
417 B
Rust

use rhai::{Engine, EvalAltResult};
#[test]
fn test_throw() {
let mut engine = Engine::new();
assert!(matches!(
engine.eval::<()>(r#"if true { throw "hello" }"#).expect_err("expects error"),
EvalAltResult::ErrorRuntime(s, _) if s == "hello"));
assert!(matches!(
engine.eval::<()>(r#"throw"#).expect_err("expects error"),
EvalAltResult::ErrorRuntime(s, _) if s == ""));
}