Loops cannot be pure.

This commit is contained in:
Stephen Chung
2021-08-04 17:37:56 +08:00
parent 81770f00e0
commit 4807fdf1cf
3 changed files with 32 additions and 4 deletions

View File

@@ -49,3 +49,16 @@ fn test_do() -> Result<(), Box<EvalAltResult>> {
Ok(())
}
#[test]
fn test_infinite_loops() -> Result<(), Box<EvalAltResult>> {
let mut engine = Engine::new();
engine.set_max_operations(1024);
assert!(engine.consume("loop {}").is_err());
assert!(engine.consume("while true {}").is_err());
assert!(engine.consume("do {} while true").is_err());
Ok(())
}