Refactor tests.
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
use rhai::Engine;
|
||||
use rhai::EvalAltResult;
|
||||
use rhai::{Engine, EvalAltResult};
|
||||
|
||||
#[test]
|
||||
fn test_decrement() {
|
||||
fn test_decrement() -> Result<(), EvalAltResult> {
|
||||
let mut engine = Engine::new();
|
||||
|
||||
assert_eq!(engine.eval::<i64>("let x = 10; x -= 7; x"), Ok(3));
|
||||
assert_eq!(engine.eval::<i64>("let x = 10; x -= 7; x")?, 3);
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<String>("let s = \"test\"; s -= \"ing\"; s"),
|
||||
Err(EvalAltResult::ErrorFunctionNotFound(
|
||||
"- (alloc::string::String, alloc::string::String)".to_string()
|
||||
))
|
||||
);
|
||||
let r = engine.eval::<String>("let s = \"test\"; s -= \"ing\"; s");
|
||||
|
||||
match r {
|
||||
Err(EvalAltResult::ErrorFunctionNotFound(err, _)) if err.starts_with("- ") => (),
|
||||
_ => panic!(),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user