summaryrefslogtreecommitdiff
path: root/tests/control_flow.toc
blob: 012978ddb1382c67dc1c0ae25a8a11dd89d96c0b (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
#include "std/io.toc", io;

f ::= fn() int {
	total := 0;
	for i := 1..10 {
		if i % 2 == 0 { continue; }
		total += i;
		if i == 7 { break; }
	}
	i := 0;
	while true {
		i += 1;
		total += i;
		if i == 10 {
			break;
		}
	}
	while i < 100 {
		i += 1;
		if i == 100 {
			return total;
		}
	}
	return 0;
}

main ::= fn() {
	x ::= f();
	io.puti(x);
	io.puti(f());
}