diff options
Diffstat (limited to 'tests/micropython/native_closure.py')
-rw-r--r-- | tests/micropython/native_closure.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/micropython/native_closure.py b/tests/micropython/native_closure.py index 6c0592e52..07014e90d 100644 --- a/tests/micropython/native_closure.py +++ b/tests/micropython/native_closure.py @@ -4,11 +4,15 @@ @micropython.native def f(): x = 1 + @micropython.native def g(): nonlocal x return x + return g + + print(f()()) # closing over an argument @@ -18,15 +22,22 @@ def f(x): def g(): nonlocal x return x + return g + + print(f(2)()) # closing over an argument and a normal local @micropython.native def f(x): y = 2 * x + @micropython.native def g(z): return x + y + z + return g + + print(f(2)(3)) |