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 mut engine = Engine::new();
|
|
|
|
|
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!(
|
2020-03-17 10:33:37 +01:00
|
|
|
engine.eval::<()>(r#"throw"#).expect_err("expects error"),
|
2020-03-14 16:40:30 +01:00
|
|
|
EvalAltResult::ErrorRuntime(s, _) if s == ""));
|
2020-03-03 11:15:20 +01:00
|
|
|
}
|