Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 121b6eb

Browse files
committed
SF patch #103749: implicit tuple + default arg
1 parent 2b3f0ca commit 121b6eb

2 files changed

Lines changed: 40 additions & 3 deletions

File tree

Lib/test/output/test_compile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
test_compile
2+
testing complex args
3+
1 2
4+
1 2
5+
3 4
6+
1 2 3
7+
1 2 3
8+
2 3 4

Lib/test/test_compile.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,49 @@
44
print 'Running tests on argument handling'
55

66
try:
7-
exec('def f(a, a): pass')
7+
exec 'def f(a, a): pass'
88
raise TestFailed, "duplicate arguments"
99
except SyntaxError:
1010
pass
1111

1212
try:
13-
exec('def f(a = 0, a = 1): pass')
13+
exec 'def f(a = 0, a = 1): pass'
1414
raise TestFailed, "duplicate keyword arguments"
1515
except SyntaxError:
1616
pass
1717

1818
try:
19-
exec('def f(a): global a; a = 1')
19+
exec 'def f(a): global a; a = 1'
2020
raise TestFailed, "variable is global and local"
2121
except SyntaxError:
2222
pass
23+
24+
print "testing complex args"
25+
26+
def comp_args((a, b)):
27+
print a,b
28+
29+
comp_args((1, 2))
30+
31+
def comp_args((a, b)=(3, 4)):
32+
print a, b
33+
34+
comp_args((1, 2))
35+
comp_args()
36+
37+
def comp_args(a, (b, c)):
38+
print a, b, c
39+
40+
comp_args(1, (2, 3))
41+
42+
def comp_args(a=2, (b, c)=(3, 4)):
43+
print a, b, c
44+
45+
comp_args(1, (2, 3))
46+
comp_args()
47+
48+
try:
49+
exec 'def f(a=1, (b, c)): pass'
50+
raise TestFailed, "non-default args after default"
51+
except SyntaxError:
52+
pass

0 commit comments

Comments
 (0)