Use matches! in examples.
This commit is contained in:
@@ -1,18 +1,14 @@
|
||||
use rhai::{Engine, EvalAltResult, INT};
|
||||
use rhai::{Engine, EvalAltResult};
|
||||
|
||||
#[test]
|
||||
fn test_throw() {
|
||||
let mut engine = Engine::new();
|
||||
|
||||
match engine.eval::<INT>(r#"if true { throw "hello" }"#) {
|
||||
Ok(_) => panic!("not an error"),
|
||||
Err(EvalAltResult::ErrorRuntime(s, _)) if s == "hello" => (),
|
||||
Err(err) => panic!("wrong error: {}", err),
|
||||
}
|
||||
assert!(matches!(
|
||||
engine.eval::<()>(r#"if true { throw "hello" }"#).expect_err("expects error"),
|
||||
EvalAltResult::ErrorRuntime(s, _) if s == "hello"));
|
||||
|
||||
match engine.eval::<INT>(r#"throw;"#) {
|
||||
Ok(_) => panic!("not an error"),
|
||||
Err(EvalAltResult::ErrorRuntime(s, _)) if s == "" => (),
|
||||
Err(err) => panic!("wrong error: {}", err),
|
||||
}
|
||||
assert!(matches!(
|
||||
engine.eval::<()>(r#"throw;"#).expect_err("expects error"),
|
||||
EvalAltResult::ErrorRuntime(s, _) if s == ""));
|
||||
}
|
||||
|
Reference in New Issue
Block a user