Debian Codegraph @

starlark/testdata/recursion.star

raw
1 # Tests of Starlark recursion and while statement.
2
3 # This is a "chunked" file: each "---" effectively starts a new file.
4
5 # option:recursion
6
7 load("assert.star", "assert")
8
9 def fib(n):
10 if n <= 1:
11 return 1
12 return fib(n-1) + fib(n-2)
13
14 assert.eq(fib(5), 8)
15
16 def runaway():
17 return runaway()
18
19 # Runaway recursion should not overflow the Go stack (#617).
20 # The interpreter imposes a limit long before then.
21 assert.fails(runaway, "Starlark stack overflow")