Refactor tests.
This commit is contained in:
@@ -1,28 +1,16 @@
|
||||
use rhai::{Engine, Scope};
|
||||
use rhai::{Engine, EvalAltResult, Scope};
|
||||
|
||||
#[test]
|
||||
fn test_var_scope() {
|
||||
fn test_var_scope() -> Result<(), EvalAltResult> {
|
||||
let mut engine = Engine::new();
|
||||
let mut scope = Scope::new();
|
||||
|
||||
assert_eq!(
|
||||
engine.eval_with_scope::<()>(&mut scope, "let x = 4 + 5"),
|
||||
Ok(())
|
||||
);
|
||||
engine.eval_with_scope::<()>(&mut scope, "let x = 4 + 5")?;
|
||||
assert_eq!(engine.eval_with_scope::<i64>(&mut scope, "x")?, 9);
|
||||
engine.eval_with_scope::<()>(&mut scope, "x = x + 1; x = x + 2;")?;
|
||||
assert_eq!(engine.eval_with_scope::<i64>(&mut scope, "x")?, 12);
|
||||
assert_eq!(engine.eval_with_scope::<()>(&mut scope, "{let x = 3}")?, ());
|
||||
assert_eq!(engine.eval_with_scope::<i64>(&mut scope, "x")?, 12);
|
||||
|
||||
assert_eq!(engine.eval_with_scope::<i64>(&mut scope, "x"), Ok(9));
|
||||
|
||||
assert_eq!(
|
||||
engine.eval_with_scope::<()>(&mut scope, "x = x + 1; x = x + 2;"),
|
||||
Ok(())
|
||||
);
|
||||
|
||||
assert_eq!(engine.eval_with_scope::<i64>(&mut scope, "x"), Ok(12));
|
||||
|
||||
assert_eq!(
|
||||
engine.eval_with_scope::<()>(&mut scope, "{let x = 3}"),
|
||||
Ok(())
|
||||
);
|
||||
|
||||
assert_eq!(engine.eval_with_scope::<i64>(&mut scope, "x"), Ok(12));
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user