-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathwrong_arguments.py
More file actions
93 lines (66 loc) · 1.06 KB
/
wrong_arguments.py
File metadata and controls
93 lines (66 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Test cases corresponding to /Expressions/Arguments/wrong_arguments.py
class F0(object):
def __init__(self, x):
pass
class F1(object):
def __init__(self, x, y = None):
pass
class F2(object):
def __init__(self, x, *y):
pass
class F3(object):
def __init__(self, x, y = None, *z):
pass
class F4(object):
def __init__(self, x, **y):
pass
class F5(object):
def __init__(self, x, y = None, **z):
pass
class F6(object):
def __init__(self, x, y):
pass
class F7(object):
def __init__(self, x, y, z):
pass
# Too few arguments
F0()
F1()
F2()
F3()
F4()
F5()
F6(1)
F7(1,2)
#Too many arguments
F0(1,2)
F1(1,2,3)
F5(1,2,3)
F6(1,2,3)
F6(1,2,3,4)
#OK
#Not too few
F7(*t)
#Not too many
F2(1,2,3,4,5,6)
#Illegal name
F0(y=1)
F1(z=1)
F2(x=0, y=1)
#Ok name
F0(x=0)
F1(x=0, y=1)
F4(q=4)
#This is correct, but a bit weird.
F6(**{'x':1, 'y':2})
t2 = (1,2)
t3 = (1,2,3)
#Ok
f(*t2)
#Too many
F6(*(1,2,3))
F6(*t3)
#Ok
F6(**{'x':1, 'y':2})
#Illegal name
F6(**{'x':1, 'y':2, 'z':3})