Restore previous always_search when exiting block.

This commit is contained in:
Stephen Chung
2020-11-21 12:25:39 +08:00
parent 6069a4cf55
commit 17cd305af7
2 changed files with 35 additions and 8 deletions

View File

@@ -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>> {