about summary refs log tree commit diff
path: root/boot/tests
diff options
context:
space:
mode:
authorMel <mel@rnrd.eu>2026-05-24 20:14:29 +0200
committerMel <mel@rnrd.eu>2026-05-24 20:14:29 +0200
commit2a893246711442dd8407264c05991b44d1d1f66f (patch)
treea0d4a621994ebb259331b7082a977e4ae2861bde /boot/tests
parentf028bc7ef3101facfa004c21f3aa5feb3dc6f107 (diff)
downloadcatskill-2a893246711442dd8407264c05991b44d1d1f66f.tar.zst
catskill-2a893246711442dd8407264c05991b44d1d1f66f.zip
Emit IR/C increment/decrement in expression position
Signed-off-by: Mel <mel@rnrd.eu>
Diffstat (limited to 'boot/tests')
-rw-r--r--boot/tests/lower/c_for_loop.cskt2
-rw-r--r--boot/tests/lower/while_loop.cskt6
-rw-r--r--boot/tests/transpile/compound_assigns.cskt13
-rw-r--r--boot/tests/transpile/loops.cskt4
4 files changed, 15 insertions, 10 deletions
diff --git a/boot/tests/lower/c_for_loop.cskt b/boot/tests/lower/c_for_loop.cskt
index 98d78f0..0006ca3 100644
--- a/boot/tests/lower/c_for_loop.cskt
+++ b/boot/tests/lower/c_for_loop.cskt
@@ -28,7 +28,7 @@ main = fun () {
 				(declaration i (ref int) (initializer (expr 0)))
 				(loop (condition (expr (binary < (expr (name i)) (expr 10)))) (block
 					(declaration x (ref int) (initializer (expr (name i))))
-					(assign (expr (name i)) (expr (binary + (expr (name i)) (expr 1))))
+					(expression-stmt (expr (postfix-++ (expr (name i)))))
 				))
 			)
 		)))
diff --git a/boot/tests/lower/while_loop.cskt b/boot/tests/lower/while_loop.cskt
index b191df5..38f8609 100644
--- a/boot/tests/lower/while_loop.cskt
+++ b/boot/tests/lower/while_loop.cskt
@@ -1,7 +1,7 @@
 while loops are 1:1 with the intermediate representation's
 single loop kind.
-compound assignments desugar into a simple pair of a simple
-assignment and binary operation.
+increment/decrement statements lower to an expression statement
+wrapping the dedicated inc/dec ir node.
 
 <<<
 
@@ -28,7 +28,7 @@ main = fun () {
 		(function 0 main main (returns (ref void)) (block
 			(declaration i (ref int) (initializer (expr 0)))
 			(loop (condition (expr (binary < (expr (name i)) (expr 10)))) (block
-				(assign (expr (name i)) (expr (binary + (expr (name i)) (expr 1))))
+				(expression-stmt (expr (postfix-++ (expr (name i)))))
 			))
 		)))
 	(emission_order 0 1 2 3 4 5 6 7))
diff --git a/boot/tests/transpile/compound_assigns.cskt b/boot/tests/transpile/compound_assigns.cskt
index e480f31..607268f 100644
--- a/boot/tests/transpile/compound_assigns.cskt
+++ b/boot/tests/transpile/compound_assigns.cskt
@@ -1,5 +1,6 @@
-compound assigns are desugared during lowering so the c output
-only ever has plain assignments.
+compound assigns desugar to plain assignment + binary; increment
+and decrement (statement or expression position) keep their own
+ir node and emit `++` / `--` directly.
 
 <<<
 
@@ -10,6 +11,8 @@ main = fun () {
     x++
     x -= 3
     x--
+    var y int = x++
+    var z int = ++x
 }
 
 >>>
@@ -20,8 +23,10 @@ void catskill_main(void) {
     integer x = 0;
     x = x + 1;
     x = x * 2;
-    x = x + 1;
+    x++;
     x = x - 3;
-    x = x - 1;
+    x--;
+    integer y = x++;
+    integer z = ++x;
 }
 #include "runtime.c"
diff --git a/boot/tests/transpile/loops.cskt b/boot/tests/transpile/loops.cskt
index d6493d9..7121538 100644
--- a/boot/tests/transpile/loops.cskt
+++ b/boot/tests/transpile/loops.cskt
@@ -23,13 +23,13 @@ void catskill_main(void);
 void catskill_main(void) {
     integer i = 0;
     while (i < 10) {
-        i = i + 1;
+        i++;
     }
     {
         integer j = 0;
         while (j < 5) {
             integer k = j;
-            j = j + 1;
+            j++;
         }
     }
     {