summaryrefslogtreecommitdiff
path: root/test.toc
diff options
context:
space:
mode:
Diffstat (limited to 'test.toc')
-rw-r--r--test.toc27
1 files changed, 21 insertions, 6 deletions
diff --git a/test.toc b/test.toc
index 9b414ad..566aed9 100644
--- a/test.toc
+++ b/test.toc
@@ -7,11 +7,26 @@ putf ::= fn(x: float) {
");
};
-main ::= fn() {
- Integer ::= id(int);
- x : Integer;
- puti(foo(x));
+SuperArray ::= fn(n :: int, t :: Type) Type {
+ struct {
+ data: [n]t;
+ field : t;
+ }
+};
+
+checksum ::= fn(t ::=, n ::=, x:SuperArray(n,t)) t {
+ total := 0 as t;
+ each i := 0..n-1 {
+ total += x.data[i];
+ }
+ total + x.field
};
-id ::= fn(t ::=, x :: t) t { x };
-foo ::= fn(t ::=, x : id(t)) int { 3 as t };
+Super ::= SuperArray(3, int);
+
+main ::= fn() {
+x: Super;
+x.data[0] = 3;
+x.field = 1932;
+puti(checksum(x));
+};