Files
micropython/tests/misc/recursive_iternext.py
Damien George 7d60a97914 tests/misc/recursive_iternext: Provide more fine-grained selection of N.
To work on a variety of ports the selection of N is very specific.
2016-06-03 15:09:45 +01:00

49 lines
914 B
Python

# This tests that recursion with iternext doesn't lead to segfault.
# We need to pick an N that is large enough to hit the recursion
# limit, but not too large that we run out of heap memory.
try:
# large stack/heap, eg unix
[0] * 80000
N = 2000
except:
try:
# medium, eg pyboard
[0] * 10000
N = 1000
except:
# small, eg esp8266
N = 100
try:
x = (1, 2)
for i in range(N):
x = enumerate(x)
tuple(x)
except RuntimeError:
print("RuntimeError")
try:
x = (1, 2)
for i in range(N):
x = filter(None, x)
tuple(x)
except RuntimeError:
print("RuntimeError")
try:
x = (1, 2)
for i in range(N):
x = map(max, x, ())
tuple(x)
except RuntimeError:
print("RuntimeError")
try:
x = (1, 2)
for i in range(N):
x = zip(x)
tuple(x)
except RuntimeError:
print("RuntimeError")