summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/init.toc15
-rw-r--r--tests/misc.toc22
-rw-r--r--tests/std/base.toc5
-rw-r--r--tests/tests.c1
-rw-r--r--tests/types.toc46
5 files changed, 44 insertions, 45 deletions
diff --git a/tests/init.toc b/tests/init.toc
index ac85058..92fb9ed 100644
--- a/tests/init.toc
+++ b/tests/init.toc
@@ -1,11 +1,3 @@
-#init(-10) init(10);
-#init(44) init(44);
-#init(22) init(22);
-#init(88) init(88);
-#init(1002389) for i := 89..100 {init(i);}
-#init(-20) init(0);
-
-
#include "std/io.toc";
total : int;
@@ -23,3 +15,10 @@ main ::= fn() {
writes("hello from main. total is ");
puti(total);
}
+
+#init init(0);
+#init init(10);
+#init init(22);
+#init init(44);
+#init init(88);
+#init for i := 89..100 {init(i);}
diff --git a/tests/misc.toc b/tests/misc.toc
index 04932e8..a6a7da5 100644
--- a/tests/misc.toc
+++ b/tests/misc.toc
@@ -1,17 +1,6 @@
#include "std/io.toc", io;
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)));
-
arr_sum ::= fn(n::=, t::=, a:[n]t) t {
total := 0 as t;
for x := a {
@@ -25,6 +14,17 @@ main ::= fn() {
a[1] = y;
a[2] = z;
};
+ 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)));
+
s ::= struct {
diff --git a/tests/std/base.toc b/tests/std/base.toc
index 54d64d6..0bd707e 100644
--- a/tests/std/base.toc
+++ b/tests/std/base.toc
@@ -7,6 +7,8 @@ PLATFORM_OPENBSD ::= 5;
PLATFORM_MISC_UNIX ::= 6;
PLATFORM ::= #builtin("platform");
+PLATFORM_IS_UNIX :: bool = PLATFORM == PLATFORM_LINUX || PLATFORM == PLATFORM_OSX || PLATFORM == PLATFORM_FREEBSD
+ || PLATFORM == PLATFORM_OPENBSD || PLATFORM == PLATFORM_MISC_UNIX;
#if PLATFORM == PLATFORM_LINUX {
libc ::= "libc.so.6";
} elif PLATFORM == PLATFORM_WINDOWS {
@@ -20,7 +22,4 @@ PLATFORM ::= #builtin("platform");
libc ::= "libc.so.6";
}
-PLATFORM_IS_UNIX :: bool = PLATFORM == PLATFORM_LINUX || PLATFORM == PLATFORM_OSX || PLATFORM == PLATFORM_FREEBSD
- || PLATFORM == PLATFORM_OPENBSD || PLATFORM == PLATFORM_MISC_UNIX;
-
diff --git a/tests/tests.c b/tests/tests.c
index 57f611e..3e49843 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -10,6 +10,7 @@ static const char *tests[] = {
"bf",
"control_flow",
"types",
+ "init",
"include",
"arrs_slices",
"ptr_arithmetic",
diff --git a/tests/types.toc b/tests/types.toc
index 25c38d5..726cc85 100644
--- a/tests/types.toc
+++ b/tests/types.toc
@@ -19,6 +19,29 @@ z ::= nms {
}
}
+slice_to_ll ::= fn(t::=, slice: []t) use ll: LinkedList(t) {
+ head = slice[0];
+ if slice.len == 1 {
+ tail = null;
+ } else {
+ tail = new(LinkedList(t));
+ *tail = slice_to_ll(slice[1:]);
+ }
+}
+
+LinkedList ::= struct (of :: Type) {
+ head: of;
+ tail: &LinkedList(of);
+}
+
+Foo ::= struct {
+ k: int;
+ b: &Bar;
+}
+
+Bar ::= struct {
+ f: Foo;
+}
main ::= fn() {
nums := news(int, 10);
@@ -45,26 +68,3 @@ main ::= fn() {
io.puti(y);
}
-slice_to_ll ::= fn(t::=, slice: []t) use ll: LinkedList(t) {
- head = slice[0];
- if slice.len == 1 {
- tail = null;
- } else {
- tail = new(LinkedList(t));
- *tail = slice_to_ll(slice[1:]);
- }
-}
-
-LinkedList ::= struct (of :: Type) {
- head: of;
- tail: &LinkedList(of);
-}
-
-Foo ::= struct {
- k: int;
- b: &Bar;
-}
-
-Bar ::= struct {
- f: Foo;
-}