Add loop test

This commit is contained in:
Dane Johnson 2024-11-16 14:29:02 -06:00
parent 03b140189c
commit c9295b5777

View File

@ -377,7 +377,19 @@ else
)];
assert_eq!(deelang_parser::program(prgm).unwrap(), expected);
}
#[test]
fn test_loop() {
let prgm = r"loop until i > 100 a";
let expected = vec![Stmt::Loop(Loop::Until(GuardedBlock {
guard: Expr::Relop(
">".to_string(),
Box::new(Expr::Id("i".to_string())),
Box::new(Expr::Atom(Atom::Num(100.0))),
),
block: vec![Stmt::BareExpr(Expr::Id("a".to_string()))],
}))];
assert_eq!(deelang_parser::program(prgm).unwrap(), expected);
}
#[test]
fn test_preprocess() {
let prgm = r"