summaryrefslogtreecommitdiffhomepage
path: root/tests/custom/02_runtime/06_recursion
blob: 470fc3a441824080a65947f39fdf4acb3e74aed0 (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
51
52
53
54
55
56
57
58
59
Testing recursive invocations.


1. Testing recursive invocation.

-- Expect stdout --
1
2
4
8
16
32
64
128
256
512
1024
2048
4096
8192
16384
-- End --

-- Testcase --
{%
	function test(x) {
		print(x, "\n");

		if (x < 10000)
			test(x * 2);
	}

	test(1);
%}
-- End --


2. Testing infinite recursion.

-- Expect stderr --
Runtime error: Too much recursion
In test(), line 3, byte 8:
  called from anonymous function ([stdin]:6:7)

 `        test();`
  Near here ---^


-- End --

-- Testcase --
{%
	function test() {
		test();
	}

	test();
%}
-- End --