From 9a687624fc6eb922acef63902aeee8986b138726 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 18 Apr 2024 21:10:11 -0500 Subject: [PATCH] stdlib: Add some funky syntax tests TODO: make stuff like this into actual lexer->parser->analysis->interpreter tests. --- stdlib/lib.cl | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/stdlib/lib.cl b/stdlib/lib.cl index 380a778..c866407 100644 --- a/stdlib/lib.cl +++ b/stdlib/lib.cl @@ -60,16 +60,6 @@ fn if_else() -> i32 { // block 4 } -fn while_else() -> i32 { - loop { - if conditional { - body; - } else { - break { else_body }; - } - } -} - #[cfg("test")] mod test { //! Tests for funky behavior @@ -96,4 +86,22 @@ mod test { StructEmpty {}, StructLike { member1: UnitLike, member2: TupleLike }, } + + fn noop () -> bool { + loop if false { + + } else break loop if false { + + } else break loop if false { + + } else break true; + } + + fn while_else() -> i32 { + while conditional { + pass + } else { + fail + } + } }