Use scope offset for variable access.

This commit is contained in:
Stephen Chung
2020-04-28 23:05:03 +08:00
parent 9ad9dd52ab
commit 304c658f89
6 changed files with 328 additions and 158 deletions

View File

@@ -34,10 +34,10 @@ fn test_eval_function() -> Result<(), Box<EvalAltResult>> {
script += "y += foo(y);";
script += "x + y";
eval(script)
eval(script) + x + y
"#
)?,
42
84
);
assert_eq!(
@@ -54,7 +54,8 @@ fn test_eval_function() -> Result<(), Box<EvalAltResult>> {
32
);
assert!(!scope.contains("z"));
assert!(scope.contains("script"));
assert_eq!(scope.len(), 3);
Ok(())
}