Add test to make sure call_fn does not pollute scope.
This commit is contained in:
parent
3f6db1d9d4
commit
c6ef2d1e95
@ -38,6 +38,10 @@ fn test_call_fn() -> Result<(), Box<EvalAltResult>> {
|
||||
fn hello() {
|
||||
41 + foo
|
||||
}
|
||||
fn define_var() {
|
||||
let bar = 21;
|
||||
bar * 2
|
||||
}
|
||||
",
|
||||
)?;
|
||||
|
||||
@ -50,6 +54,11 @@ fn test_call_fn() -> Result<(), Box<EvalAltResult>> {
|
||||
let r: INT = engine.call_fn(&mut scope, &ast, "hello", ())?;
|
||||
assert_eq!(r, 42);
|
||||
|
||||
let r: INT = engine.call_fn(&mut scope, &ast, "define_var", ())?;
|
||||
assert_eq!(r, 42);
|
||||
|
||||
assert!(!scope.contains("bar"));
|
||||
|
||||
assert_eq!(
|
||||
scope
|
||||
.get_value::<INT>("foo")
|
||||
|
Loading…
Reference in New Issue
Block a user