Add counter variable to for statement.
This commit is contained in:
16
tests/for.rs
16
tests/for.rs
@@ -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>(
|
||||
"
|
||||
|
Reference in New Issue
Block a user