summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/02_runtime/01_break_continue
blob: a27d0727cd4672c570a1901c0b09652827b3f2bb (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
44
45
46
47
48
49
50
The "break" and "continue" statements allow to abort a running loop or to
prematurely advance to the next cycle.

-- Expect stdout --
Testing break:
 - Iteration 0
 - Iteration 1
 - Iteration 2
 - Iteration 3
 - Iteration 4
 - Iteration 5
 - Iteration 6
 - Iteration 7
 - Iteration 8
 - Iteration 9
 - Iteration 10

Testing continue:
 - Iteration 0
 - Iteration 2
 - Iteration 4
 - Iteration 6
 - Iteration 8
-- End --

-- Testcase --
Testing break:
{%
	let i = 0;

	while (true) {
		print(" - Iteration ", i, "\n");

		if (i == 10)
			break;

		i++;
	}
%}

Testing continue:
{%
	for (i = 0; i < 10; i++) {
		if (i % 2)
			continue;

		print(" - Iteration ", i, "\n");
	}
%}
-- End --