From c9295b5777f6668e402ddef7e268e068ae35174e Mon Sep 17 00:00:00 2001 From: Dane Johnson Date: Sat, 16 Nov 2024 14:29:02 -0600 Subject: [PATCH] Add loop test --- src/parser.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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"