about summary refs log tree commit diff
path: root/boot/tests/transpile/loops.cskt
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2026-05-06 18:48:56 +0200
committerMel <mel@rnrd.eu>2026-05-06 18:48:56 +0200
commitac696b22b3f03ae9670a9d1d154ce7ff848b5e55 (patch)
treee1f7ac3e1cd1f545d1ab0c1dc5c19130a9b23c5f /boot/tests/transpile/loops.cskt
parent3850a7b311bca7bae925aeea456a41036f116ebd (diff)
downloadcatskill-ac696b22b3f03ae9670a9d1d154ce7ff848b5e55.tar.zst
catskill-ac696b22b3f03ae9670a9d1d154ce7ff848b5e55.zip
Tests for new IR transpiler
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'boot/tests/transpile/loops.cskt')
-rw-r--r--boot/tests/transpile/loops.cskt43
1 files changed, 43 insertions, 0 deletions
diff --git a/boot/tests/transpile/loops.cskt b/boot/tests/transpile/loops.cskt
new file mode 100644
index 0000000..d6493d9
--- /dev/null
+++ b/boot/tests/transpile/loops.cskt
@@ -0,0 +1,43 @@
+while loops are 1:1; c-style and range for-each both desugar to
+a `{ var; while { body; iter; } }` block.
+
+<<<
+
+main = fun () {
+    var i int = 0
+    while i < 10 {
+        i++
+    }
+    for j int = 0, j < 5, j++ {
+        var k int = j
+    }
+    for r int = 0..3 {
+        var s int = r
+    }
+}
+
+>>>
+
+#include "core.c"
+void catskill_main(void);
+void catskill_main(void) {
+    integer i = 0;
+    while (i < 10) {
+        i = i + 1;
+    }
+    {
+        integer j = 0;
+        while (j < 5) {
+            integer k = j;
+            j = j + 1;
+        }
+    }
+    {
+        integer r = 0;
+        while (r < 3) {
+            integer s = r;
+            r = r + 1;
+        }
+    }
+}
+#include "runtime.c"