rhai/tests/looping.rs

28 lines
311 B
Rust
Raw Normal View History

use rhai::Engine;
2017-11-03 17:58:51 +01:00
#[test]
fn test_loop() {
2019-09-18 12:21:07 +02:00
let mut engine = Engine::new();
2017-11-03 17:58:51 +01:00
2019-09-18 12:21:07 +02:00
assert!(engine
.eval::<bool>(
"
2017-11-03 17:58:51 +01:00
let x = 0;
let i = 0;
loop {
if i < 10 {
x = x + i;
i = i + 1;
}
else {
break;
}
}
x == 45
2019-09-18 12:21:07 +02:00
"
)
.unwrap())
2017-11-03 17:58:51 +01:00
}