Refine tests.
This commit is contained in:
@@ -4,7 +4,7 @@ use rhai::{Engine, EvalAltResult, RegisterFn, INT};
|
||||
|
||||
#[test]
|
||||
fn test_method_call() -> Result<(), EvalAltResult> {
|
||||
#[derive(Clone)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
struct TestStruct {
|
||||
x: INT,
|
||||
}
|
||||
@@ -26,11 +26,15 @@ fn test_method_call() -> Result<(), EvalAltResult> {
|
||||
engine.register_fn("update", TestStruct::update);
|
||||
engine.register_fn("new_ts", TestStruct::new);
|
||||
|
||||
let ts = engine.eval::<TestStruct>("let x = new_ts(); x.update(); x")?;
|
||||
assert_eq!(ts.x, 1001);
|
||||
assert_eq!(
|
||||
engine.eval::<TestStruct>("let x = new_ts(); x.update(); x")?,
|
||||
TestStruct { x: 1001 }
|
||||
);
|
||||
|
||||
let ts = engine.eval::<TestStruct>("let x = new_ts(); update(x); x")?;
|
||||
assert_eq!(ts.x, 1);
|
||||
assert_eq!(
|
||||
engine.eval::<TestStruct>("let x = new_ts(); update(x); x")?,
|
||||
TestStruct { x: 1 }
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user