From ac696b22b3f03ae9670a9d1d154ce7ff848b5e55 Mon Sep 17 00:00:00 2001 From: Mel Date: Wed, 6 May 2026 18:48:56 +0200 Subject: Tests for new IR transpiler Signed-off-by: Mel --- boot/tests/transpile/conditionals.cskt | 37 ++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 boot/tests/transpile/conditionals.cskt (limited to 'boot/tests/transpile/conditionals.cskt') diff --git a/boot/tests/transpile/conditionals.cskt b/boot/tests/transpile/conditionals.cskt new file mode 100644 index 0000000..96c3877 --- /dev/null +++ b/boot/tests/transpile/conditionals.cskt @@ -0,0 +1,37 @@ +if/else-if/else chains and nested conditionals emit as a single +chained `if () { } else if () { } else { }` c block. + +<<< + +classify = fun (n int) int { + if n < 0 { + return -1 + } else if n == 0 { + return 0 + } else { + return 1 + } +} + +main = fun () { + classify(5) +} + +>>> + +#include "core.c" +integer classify(integer n); +void catskill_main(void); +integer classify(integer n) { + if (n < 0) { + return -1; + } else if (n == 0) { + return 0; + } else { + return 1; + } +} +void catskill_main(void) { + classify(5); +} +#include "runtime.c" -- cgit 1.4.1