Cython has moved to github.
cython-devel
view tests/run/kwonlyargs.pyx @ 1622:4f0327bdebc9
test for temp allocation bug in call
| author | Robert Bradshaw <robertwb@math.washington.edu> |
|---|---|
| date | Sat Jan 17 01:25:34 2009 -0800 (3 years ago) |
| parents | cb2210928a0a |
| children | 82d312a9f1fc |
line source
1 __doc__ = u"""
2 >>> b(1,2,3)
3 >>> b(1,2,3,4)
4 Traceback (most recent call last):
5 TypeError: b() takes exactly 3 positional arguments (4 given)
7 >>> c(1,2)
8 >>> c(1,2,3)
9 >>> c(1,2,3,4)
10 Traceback (most recent call last):
11 TypeError: c() takes at most 3 positional arguments (4 given)
13 >>> d(1,2)
14 >>> d(1,2, c=1)
16 >>> d(1,2,3)
17 Traceback (most recent call last):
18 TypeError: d() takes exactly 2 positional arguments (3 given)
19 >>> d(1,2, d=1)
20 Traceback (most recent call last):
21 TypeError: d() got an unexpected keyword argument 'd'
23 >>> e(1,2)
24 >>> e(1,2, c=1)
25 >>> e(1,2, d=1)
26 >>> e(1,2, c=1, d=2, e=3)
27 >>> e(1,2,3)
28 >>> e(1,2,3,4)
29 Traceback (most recent call last):
30 TypeError: e() takes at most 3 positional arguments (4 given)
32 >>> f(1,2, c=1)
33 >>> f(1,2, c=1, d=2)
35 >>> f(1,2,3)
36 Traceback (most recent call last):
37 TypeError: f() takes exactly 2 positional arguments (3 given)
38 >>> f(1,2)
39 Traceback (most recent call last):
40 TypeError: f() needs keyword-only argument c
41 >>> f(1,2, c=1, e=2)
42 Traceback (most recent call last):
43 TypeError: f() got an unexpected keyword argument 'e'
45 >>> g(1,2, c=1, f=2)
46 >>> g(1,2, c=1, e=0, f=2, d=11)
47 >>> g(1,2, c=1, f=2, e=0, x=25)
49 >>> g(1,2,3)
50 Traceback (most recent call last):
51 TypeError: g() takes exactly 2 positional arguments (3 given)
52 >>> g(1,2)
53 Traceback (most recent call last):
54 TypeError: g() needs keyword-only argument c
55 >>> g(1,2, c=1)
56 Traceback (most recent call last):
57 TypeError: g() needs keyword-only argument f
59 >>> h(1,2, c=1, f=2)
60 >>> h(1,2, c=1, f=2, e=3)
61 >>> h(1,2,3,4,5,6, c=1, f=2)
62 >>> h(1,2,3,4,5,6, c=1, f=2, e=3, x=25, y=11)
64 >>> h(1,2,3)
65 Traceback (most recent call last):
66 TypeError: h() needs keyword-only argument c
67 >>> h(1,2, d=1)
68 Traceback (most recent call last):
69 TypeError: h() needs keyword-only argument c
71 >>> k(1,2, c=1, f=2)
72 >>> k(1,2, c=1, f=2, e=3)
73 >>> k(1,2,3,4,5,6, d=1, f=2)
74 >>> k(1,2,3,4,5,6, d=1, f=2, e=3, x=25, y=11)
76 >>> k(1,2,3)
77 Traceback (most recent call last):
78 TypeError: k() needs keyword-only argument f
79 >>> k(1,2, d=1)
80 Traceback (most recent call last):
81 TypeError: k() needs keyword-only argument f
83 >>> l(a=1, b=2)
84 >>> l(a=1, b=2, c=1)
86 >>> l(1,2,3)
87 Traceback (most recent call last):
88 TypeError: l() takes exactly 0 positional arguments (3 given)
89 >>> l(1,2, d=1)
90 Traceback (most recent call last):
91 TypeError: l() takes exactly 0 positional arguments (2 given)
93 >>> m(1, b=2)
94 >>> m(a=1, b=2)
95 >>> m(a=1, b=2, c=1)
97 >>> l(1,2,3)
98 Traceback (most recent call last):
99 TypeError: l() takes exactly 0 positional arguments (3 given)
100 >>> l(1,2, d=1)
101 Traceback (most recent call last):
102 TypeError: l() takes exactly 0 positional arguments (2 given)
103 """
105 def b(a, b, c):
106 a, b, c = b, c, a
108 def c(a, b, c=1):
109 a, b, c = b, c, a
111 def d(a, b, *, c = 88):
112 a, b, c = b, c, a
114 def e(a, b, c = 88, **kwds):
115 a, b, c = b, c, a
117 def f(a, b, *, c, d = 42):
118 a, b, c, d = b, c, d, a
120 def g(a, b, *, c, d = 42, e = 17, f, **kwds):
121 a, b, c, d, e, f = b, c, d, e, f, a
123 def h(a, b, *args, c, d = 42, e = 17, f, **kwds):
124 a, b, c, d, e, f = b, c, d, e, f, a
126 def k(a, b, c=1, *args, d = 42, e = 17, f, **kwds):
127 a, b, c, d, e, f = b, c, d, e, f, a
129 def l(*, a, b, c = 88):
130 a, b, c = b, c, a
132 def m(a, *, b, c = 88):
133 a, b, c = b, c, a
135 def n(a, *, b, c = 88):
136 a, b, c = b, c, a
