summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics')
-rw-r--r--tests/basics/fun-defargs.py2
-rw-r--r--tests/basics/fun-kwonly.py9
-rw-r--r--tests/basics/fun-kwonlydef.py36
-rw-r--r--tests/basics/getattr1.py1
4 files changed, 38 insertions, 10 deletions
diff --git a/tests/basics/fun-defargs.py b/tests/basics/fun-defargs.py
index 0666b8c494..ed25f5739d 100644
--- a/tests/basics/fun-defargs.py
+++ b/tests/basics/fun-defargs.py
@@ -1,5 +1,5 @@
def fun1(val=5):
- print(5)
+ print(val)
fun1()
fun1(10)
diff --git a/tests/basics/fun-kwonly.py b/tests/basics/fun-kwonly.py
index 8bda68d95a..bdff3a8210 100644
--- a/tests/basics/fun-kwonly.py
+++ b/tests/basics/fun-kwonly.py
@@ -43,15 +43,6 @@ def f(a, *, b, **kw):
f(1, b=2)
f(1, b=2, c=3)
-## with a default value; not currently working
-#def g(a, *, b=2, c):
-# print(a, b, c)
-#
-#g(1, c=3)
-#g(1, b=3, c=4)
-#g(1, **{'c':3})
-#g(1, **{'b':'3', 'c':4})
-
# with named star
def f(*a, b, c):
print(a, b, c)
diff --git a/tests/basics/fun-kwonlydef.py b/tests/basics/fun-kwonlydef.py
new file mode 100644
index 0000000000..56a08ee81c
--- /dev/null
+++ b/tests/basics/fun-kwonlydef.py
@@ -0,0 +1,36 @@
+# test function args, keyword only with default value
+
+# a single arg with a default
+def f1(*, a=1):
+ print(a)
+f1()
+f1(a=2)
+
+# 1 arg default, 1 not
+def f2(*, a=1, b):
+ print(a, b)
+f2(b=2)
+f2(a=2, b=3)
+
+# 1 positional, 1 arg default, 1 not
+def f3(a, *, b=2, c):
+ print(a, b, c)
+f3(1, c=3)
+f3(1, b=3, c=4)
+f3(1, **{'c':3})
+f3(1, **{'b':'3', 'c':4})
+
+# many args, not all with defaults
+def f4(*, a=1, b, c=3, d, e=5, f):
+ print(a, b, c, d, e, f)
+f4(b=2, d=4, f=6)
+f4(a=11, b=2, d=4, f=6)
+f4(a=11, b=2, c=33, d=4, e=55, f=6)
+f4(f=6, e=55, d=4, c=33, b=2, a=11)
+
+# positional with default, then keyword only
+def f5(a, b=4, *c, d=8):
+ print(a, b, c, d)
+f5(1)
+f5(1, d=9)
+f5(1, b=44, d=9)
diff --git a/tests/basics/getattr1.py b/tests/basics/getattr1.py
index 9a96154ca5..59cb7e7f7a 100644
--- a/tests/basics/getattr1.py
+++ b/tests/basics/getattr1.py
@@ -15,3 +15,4 @@ print(getattr(a, "var2"))
print(getattr(a, "meth")(5))
print(getattr(a, "_none_such", 123))
print(getattr(list, "foo", 456))
+print(getattr(a, "va" + "r2"))