aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-05-04 22:23:38 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-05-04 22:23:38 +0300
commit2026bf974cffb5d560287ba8d44ea3ecd9204853 (patch)
treeee41977fce6b08e9ade7e13f5a95fad2a64aec03 /tests
parent0be2e0813a29ee4cb93f07fdd868ca4f0c069f02 (diff)
downloadek-2026bf974cffb5d560287ba8d44ea3ecd9204853.tar.gz
ek-2026bf974cffb5d560287ba8d44ea3ecd9204853.zip
test recursion
+ Not executable, but parsing and type checking seems to work
Diffstat (limited to 'tests')
-rw-r--r--tests/fib.ek20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/fib.ek b/tests/fib.ek
new file mode 100644
index 0000000..a9cc5fb
--- /dev/null
+++ b/tests/fib.ek
@@ -0,0 +1,20 @@
+typedef bool {}
+typedef i27 {}
+typedef i9 {}
+
+extern _putchar(i9 c);
+
+fib(i27 n => i27)
+{
+ if n < 2 {
+ return 1;
+ }
+
+ return fib(n - 1) + fib(n - 2);
+}
+
+main()
+{
+ _putchar('0' + fib(35) as i9);
+ _putchar('\n');
+}