summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/fun_defargs.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-12-12 13:42:51 +0000
committerDamien George <damien.p.george@gmail.com>2015-12-12 13:42:51 +0000
commit29e9db0c587145a8823227635734924896cdc4d1 (patch)
tree5154dbd6aefce46f4ea015a2891efe95d46383f7 /tests/basics/fun_defargs.py
parentbb7f5b55010a3957bad30fbb505664e385b290b6 (diff)
downloadmicropython-29e9db0c587145a8823227635734924896cdc4d1.tar.gz
micropython-29e9db0c587145a8823227635734924896cdc4d1.zip
py: Fix compiler to handle lambdas used as default arguments.
Addresses issue #1709.
Diffstat (limited to 'tests/basics/fun_defargs.py')
-rw-r--r--tests/basics/fun_defargs.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/basics/fun_defargs.py b/tests/basics/fun_defargs.py
index ed25f5739d..1466c44094 100644
--- a/tests/basics/fun_defargs.py
+++ b/tests/basics/fun_defargs.py
@@ -1,3 +1,5 @@
+# testing default args to a function
+
def fun1(val=5):
print(val)
@@ -18,3 +20,10 @@ try:
fun2(1, 2, 3, 4)
except TypeError:
print("TypeError")
+
+# lambda as default arg (exposes nested behaviour in compiler)
+def f(x=lambda:1):
+ return x()
+print(f())
+print(f(f))
+print(f(lambda:2))