Add counter variable to for statement.

This commit is contained in:
Stephen Chung
2021-06-07 11:01:16 +08:00
parent 989cb702c0
commit 1e66f1963a
7 changed files with 132 additions and 33 deletions

View File

@@ -37,6 +37,22 @@ fn test_for_loop() -> Result<(), Box<EvalAltResult>> {
35
);
#[cfg(not(feature = "no_index"))]
assert_eq!(
engine.eval::<INT>(
"
let sum = 0;
let inputs = [1, 2, 3, 4, 5];
for (x, i) in inputs {
sum += x * (i + 1);
}
sum
"
)?,
55
);
assert_eq!(
engine.eval::<INT>(
"