We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6647d03 commit 095f90fCopy full SHA for 095f90f
2 files changed
tests/micropython/native_gen.py
@@ -0,0 +1,21 @@
1
+# test for native generators
2
+
3
+# simple generator with yield and return
4
+@micropython.native
5
+def gen1(x):
6
+ yield x
7
+ yield x + 1
8
+ return x + 2
9
+g = gen1(3)
10
+print(next(g))
11
12
+try:
13
+ next(g)
14
+except StopIteration as e:
15
+ print(e.args[0])
16
17
+# using yield from
18
19
+def gen2(x):
20
+ yield from range(x)
21
+print(list(gen2(3)))
tests/micropython/native_gen.py.exp
@@ -0,0 +1,4 @@
+3
+4
+5
+[0, 1, 2]
0 commit comments