summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-02-19 23:53:42 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-02-19 23:53:42 (GMT)
commit121b6eb018a839bfaf6af22ceb1a9793e62428df (patch)
tree687accdfa54eac1ab7e86a31e823c640ede1d1c8 /Lib/test
parent2b3f0ca2aca13733dbffd32098b3e69c17e841b8 (diff)
downloadcpython-121b6eb018a839bfaf6af22ceb1a9793e62428df.zip
cpython-121b6eb018a839bfaf6af22ceb1a9793e62428df.tar.gz
cpython-121b6eb018a839bfaf6af22ceb1a9793e62428df.tar.bz2
SF patch #103749: implicit tuple + default arg
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/output/test_compile7
-rw-r--r--Lib/test/test_compile.py36
2 files changed, 40 insertions, 3 deletions
diff --git a/Lib/test/output/test_compile b/Lib/test/output/test_compile
index 357f96d..de33352 100644
--- a/Lib/test/output/test_compile
+++ b/Lib/test/output/test_compile
@@ -1 +1,8 @@
test_compile
+testing complex args
+1 2
+1 2
+3 4
+1 2 3
+1 2 3
+2 3 4
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index dff7758..cb24060 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -4,19 +4,49 @@ if verbose:
print 'Running tests on argument handling'
try:
- exec('def f(a, a): pass')
+ exec 'def f(a, a): pass'
raise TestFailed, "duplicate arguments"
except SyntaxError:
pass
try:
- exec('def f(a = 0, a = 1): pass')
+ exec 'def f(a = 0, a = 1): pass'
raise TestFailed, "duplicate keyword arguments"
except SyntaxError:
pass
try:
- exec('def f(a): global a; a = 1')
+ exec 'def f(a): global a; a = 1'
raise TestFailed, "variable is global and local"
except SyntaxError:
pass
+
+print "testing complex args"
+
+def comp_args((a, b)):
+ print a,b
+
+comp_args((1, 2))
+
+def comp_args((a, b)=(3, 4)):
+ print a, b
+
+comp_args((1, 2))
+comp_args()
+
+def comp_args(a, (b, c)):
+ print a, b, c
+
+comp_args(1, (2, 3))
+
+def comp_args(a=2, (b, c)=(3, 4)):
+ print a, b, c
+
+comp_args(1, (2, 3))
+comp_args()
+
+try:
+ exec 'def f(a=1, (b, c)): pass'
+ raise TestFailed, "non-default args after default"
+except SyntaxError:
+ pass