Use ? operator in tests.
This commit is contained in:
@@ -4,7 +4,7 @@ use rhai::{Engine, EvalAltResult};
|
||||
fn test_engine_call_fn() -> Result<(), EvalAltResult> {
|
||||
let mut engine = Engine::new();
|
||||
|
||||
let ast = Engine::compile("fn hello(x, y) { x.len() + y }")?;
|
||||
let ast = engine.compile("fn hello(x, y) { x.len() + y }")?;
|
||||
|
||||
let result: i64 = engine.call_fn("hello", &ast, (&mut String::from("abc"), &mut 123_i64))?;
|
||||
|
||||
|
@@ -40,9 +40,9 @@ fn test_scope_eval() -> Result<(), EvalAltResult> {
|
||||
.expect("y and z not found?");
|
||||
|
||||
// Second invocation using the same state
|
||||
if let Ok(result) = engine.eval_with_scope::<i64>(&mut scope, "x") {
|
||||
println!("result: {}", result); // should print 966
|
||||
}
|
||||
let result = engine.eval_with_scope::<i64>(&mut scope, "x")?;
|
||||
|
||||
println!("result: {}", result); // should print 966
|
||||
|
||||
// Variable y is changed in the script
|
||||
assert_eq!(scope.get_value::<i64>("y").unwrap(), 1);
|
||||
|
Reference in New Issue
Block a user