Restore previous always_search when exiting block.
This commit is contained in:
@@ -8,7 +8,7 @@ fn test_eval() -> Result<(), Box<EvalAltResult>> {
|
||||
engine.eval::<INT>(
|
||||
r#"
|
||||
eval("40 + 2")
|
||||
"#
|
||||
"#
|
||||
)?,
|
||||
42
|
||||
);
|
||||
@@ -16,6 +16,33 @@ fn test_eval() -> Result<(), Box<EvalAltResult>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_eval_blocks() -> Result<(), Box<EvalAltResult>> {
|
||||
let engine = Engine::new();
|
||||
|
||||
assert_eq!(
|
||||
engine.eval::<INT>(
|
||||
r#"
|
||||
let x = 999;
|
||||
|
||||
eval("let x = x + 123");
|
||||
|
||||
let y = if x > 0 {
|
||||
eval("let x = 42");
|
||||
x
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
x + y
|
||||
"#
|
||||
)?,
|
||||
1164
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "no_function"))]
|
||||
fn test_eval_function() -> Result<(), Box<EvalAltResult>> {
|
||||
|
Reference in New Issue
Block a user