circuitpython/tests/stress/recursive_gen.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

25 lines
338 B
Python
Raw Normal View History

# test deeply recursive generators
2023-02-01 03:08:41 -05:00
# simple "yield from" recursion
def gen():
yield from gen()
2021-03-15 09:57:36 -04:00
try:
list(gen())
except RuntimeError:
2021-03-15 09:57:36 -04:00
print("RuntimeError")
2023-02-01 03:08:41 -05:00
# recursion via an iterator over a generator
def gen2():
for x in gen2():
yield x
2021-03-15 09:57:36 -04:00
try:
next(gen2())
except RuntimeError:
2021-03-15 09:57:36 -04:00
print("RuntimeError")