pocketlang/tests/lang/functions.pk
Thakee Nathees 227be9aab5 local variable miss-calculation bug fix
for nested functions the count of locals and the required stack size
are miss-calculated, ie. No new count wasn't started for inner functions
it makes the required stack size greater than or equal to it's enclosing
functions stack size.
2022-04-12 16:29:20 +05:30

22 lines
391 B
Plaintext

## Function Tests.
def f1 return 'f1' end assert(f1() == 'f1')
def f2() return 'f2' end assert(f2() == 'f2')
def f3(a, b, c, d) return c end
assert(f3('a', 'b', 'c', 'd') == 'c')
## Local variables of inner funcions.
def f4
l1 = 3.14
f5 = func
l2 = 42
return l2
end
assert(f5() == 42)
end
f4()
# If we got here, that means all test were passed.
print('All TESTS PASSED')