summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/misc.toc27
-rw-r--r--tests/misc_expected4
-rwxr-xr-xtests/test.sh20
3 files changed, 44 insertions, 7 deletions
diff --git a/tests/misc.toc b/tests/misc.toc
new file mode 100644
index 0000000..d66972f
--- /dev/null
+++ b/tests/misc.toc
@@ -0,0 +1,27 @@
+#include "io.toc", io;
+
+arr_sum ::= fn(n::=, t::=, a:[n]t) t {
+ total := 0 as t;
+ for x := a {
+ total += x;
+ }
+ total
+};
+
+mk_arr ::= fn(x:int, y:int, z:int) a:[3]int {
+ a[0] = x;
+ a[1] = y;
+ a[2] = z;
+};
+
+main ::= fn() {
+ x ::= 3;
+ #if x > 2 {
+ io.puts("Hello!");
+ } else {
+ foo("yes");
+ }
+ io.puti(arr_sum(mk_arr(5,89,22)));
+ io.puti(arr_sum(mk_arr(1,2,3)));
+ io.puti(arr_sum(mk_arr(z=0, 0, 0)));
+}; \ No newline at end of file
diff --git a/tests/misc_expected b/tests/misc_expected
new file mode 100644
index 0000000..92e0278
--- /dev/null
+++ b/tests/misc_expected
@@ -0,0 +1,4 @@
+Hello!
+116
+6
+0
diff --git a/tests/test.sh b/tests/test.sh
index 1d47dff..b0b27e1 100755
--- a/tests/test.sh
+++ b/tests/test.sh
@@ -1,4 +1,14 @@
#!/bin/bash
+
+tests='bf
+arr
+arr2
+arr3
+foreign
+params
+nms
+misc'
+
STARTPWD=$(pwd)
cd $(pwd)/$(dirname $0)
TOC=../toc
@@ -31,12 +41,8 @@ do_tests() {
fi
done
}
+for x in $tests; do
+ do_tests "$x"
+done
-do_tests bf
-do_tests arr
-do_tests arr2
-do_tests arr3
-do_tests foreign
-do_tests params
-do_tests nms
rm got a.out out.c