summaryrefslogtreecommitdiff
path: root/tests/basics
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics')
-rw-r--r--tests/basics/fun_defargs.py9
-rw-r--r--tests/basics/fun_kwonly.py7
2 files changed, 16 insertions, 0 deletions
diff --git a/tests/basics/fun_defargs.py b/tests/basics/fun_defargs.py
index ed25f5739..1466c4409 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))
diff --git a/tests/basics/fun_kwonly.py b/tests/basics/fun_kwonly.py
index bdff3a821..7694c8ddc 100644
--- a/tests/basics/fun_kwonly.py
+++ b/tests/basics/fun_kwonly.py
@@ -57,3 +57,10 @@ def f(a, *b, c):
f(1, c=2)
f(1, 2, c=3)
f(a=1, c=3)
+
+# lambda as kw-only arg (exposes nested behaviour in compiler)
+def f(*, x=lambda:1):
+ return x()
+print(f())
+print(f(x=f))
+print(f(x=lambda:2))