summaryrefslogtreecommitdiff
path: root/tests/misc.toc
blob: a6a7da54e73d0135d0628e70ecb3a70900b094f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "std/io.toc", io;

main ::= fn() {
	arr_sum ::= fn(n::=, t::=, a:[n]t) t {
		total := 0 as t;
		for x := a {
			total += x;
		}
		return total;
	};

	mk_arr ::= fn(x:int, y:int, z:int) a:[3]int {
		a[0] = x;
		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 {
		foo, e: int;
		bar ::= 3;
		baz: float;
	}

	p: s;
	p.e = 100;
	io.puti(p["bar"]);
	io.puti(p["e"]);

	foo := 4483 as ∫ #no_warn
	io.puti(foo as int); #no_warn
};