]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
SF patch #103749: implicit tuple + default arg
authorJeremy Hylton <jeremy@alum.mit.edu>
Mon, 19 Feb 2001 23:53:42 +0000 (23:53 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Mon, 19 Feb 2001 23:53:42 +0000 (23:53 +0000)
Lib/test/output/test_compile
Lib/test/test_compile.py

index 357f96d4b88ffbc8749f3d3b718b5dfaa214c608..de3335276b515f408de2f10fb58b8fb92ea08075 100644 (file)
@@ -1 +1,8 @@
 test_compile
+testing complex args
+1 2
+1 2
+3 4
+1 2 3
+1 2 3
+2 3 4
index dff775803868d96ecf1fb7b3879087d2298f1ebf..cb240601aa3029d671237c2819ae0b14dd40d633 100644 (file)
@@ -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