mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
tests/basics/iter1.py: Add more tests for walking a user-defined iter.
Some code in mp_iternext() was only tested by the native emitter, so the tests added here test this function using just the bytecode emitter.
This commit is contained in:
@@ -68,3 +68,12 @@ except StopIteration:
|
|||||||
|
|
||||||
for i in myiter(32):
|
for i in myiter(32):
|
||||||
print(i)
|
print(i)
|
||||||
|
|
||||||
|
# repeat some of the above tests but use tuple() to walk the iterator (tests mp_iternext)
|
||||||
|
print(tuple(myiter(5)))
|
||||||
|
print(tuple(myiter(12)))
|
||||||
|
print(tuple(myiter(32)))
|
||||||
|
try:
|
||||||
|
tuple(myiter(22))
|
||||||
|
except TypeError:
|
||||||
|
print('raised TypeError')
|
||||||
|
|||||||
Reference in New Issue
Block a user