diff --git a/src/parser.rs b/src/parser.rs index 4876ddc..075c930 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -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"