Refactor tests.

This commit is contained in:
Stephen Chung
2020-03-02 22:11:56 +08:00
parent ed8d2ac20f
commit 0707fad1ca
27 changed files with 338 additions and 317 deletions

View File

@@ -1,8 +1,7 @@
use rhai::Engine;
use rhai::RegisterFn;
use rhai::{Engine, EvalAltResult, RegisterFn};
#[test]
fn test_method_call() {
fn test_method_call() -> Result<(), EvalAltResult> {
#[derive(Clone)]
struct TestStruct {
x: i64,
@@ -25,9 +24,9 @@ fn test_method_call() {
engine.register_fn("update", TestStruct::update);
engine.register_fn("new_ts", TestStruct::new);
if let Ok(result) = engine.eval::<TestStruct>("let x = new_ts(); x.update(); x") {
assert_eq!(result.x, 1001);
} else {
assert!(false);
}
let ts = engine.eval::<TestStruct>("let x = new_ts(); x.update(); x")?;
assert_eq!(ts.x, 1001);
Ok(())
}