Replace unwrap with expect.
This commit is contained in:
@@ -59,21 +59,21 @@ fn test_optimizer_parse() -> Result<(), Box<EvalAltResult>> {
|
||||
|
||||
assert_eq!(
|
||||
format!("{:?}", ast),
|
||||
"AST { source: None, body: [Expr(123 @ 1:53)], functions: Module, resolver: None }"
|
||||
"AST { source: None, body: Block[Expr(123 @ 1:53)], functions: Module, resolver: None }"
|
||||
);
|
||||
|
||||
let ast = engine.compile("const DECISION = false; if DECISION { 42 } else { 123 }")?;
|
||||
|
||||
assert_eq!(
|
||||
format!("{:?}", ast),
|
||||
r#"AST { source: None, body: [Const(false @ 1:18, "DECISION" @ 1:7, false, 1:1), Expr(123 @ 1:51)], functions: Module, resolver: None }"#
|
||||
r#"AST { source: None, body: Block[Const(false @ 1:18, "DECISION" @ 1:7, false, 1:1), Expr(123 @ 1:51)], functions: Module, resolver: None }"#
|
||||
);
|
||||
|
||||
let ast = engine.compile("if 1 == 2 { 42 }")?;
|
||||
|
||||
assert_eq!(
|
||||
format!("{:?}", ast),
|
||||
"AST { source: None, body: [], functions: Module, resolver: None }"
|
||||
"AST { source: None, body: Block[], functions: Module, resolver: None }"
|
||||
);
|
||||
|
||||
engine.set_optimization_level(OptimizationLevel::Full);
|
||||
@@ -82,7 +82,7 @@ fn test_optimizer_parse() -> Result<(), Box<EvalAltResult>> {
|
||||
|
||||
assert_eq!(
|
||||
format!("{:?}", ast),
|
||||
"AST { source: None, body: [Expr(42 @ 1:1)], functions: Module, resolver: None }"
|
||||
"AST { source: None, body: Block[Expr(42 @ 1:1)], functions: Module, resolver: None }"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
|
@@ -61,7 +61,7 @@ fn test_scope_eval() -> Result<(), Box<EvalAltResult>> {
|
||||
// First invocation
|
||||
engine
|
||||
.eval_with_scope::<()>(&mut scope, " let x = 4 + 5 - y + z; y = 1;")
|
||||
.expect("y and z not found?");
|
||||
.expect("variables y and z should exist");
|
||||
|
||||
// Second invocation using the same state
|
||||
let result = engine.eval_with_scope::<INT>(&mut scope, "x")?;
|
||||
|
Reference in New Issue
Block a user