Cython has moved to github.

cython-devel

view tests/run/kwonlyargscall.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 ffc0e94c4fef
children 82d312a9f1fc
line source
1 __doc__ = u"""
2 >>> call0ab(b)
3 Traceback (most recent call last):
4 TypeError: b() takes exactly 3 positional arguments (2 given)
5 >>> call0abc(b)
6 1 2 3
7 >>> call3(b)
8 1 2 3
9 >>> call4(b)
10 Traceback (most recent call last):
11 TypeError: b() takes exactly 3 positional arguments (4 given)
13 >>> call0ab(c)
14 1 2 1
15 >>> call0abc(c)
16 1 2 3
17 >>> call2(c)
18 1 2 1
19 >>> call3(c)
20 1 2 3
21 >>> call4(c)
22 Traceback (most recent call last):
23 TypeError: c() takes at most 3 positional arguments (4 given)
25 >>> call0abc(d)
26 1 2 3
27 >>> call0ab(d)
28 1 2 88
29 >>> call2(d)
30 1 2 88
31 >>> call2c(d)
32 1 2 1
34 >>> call3(d)
35 Traceback (most recent call last):
36 TypeError: d() takes exactly 2 positional arguments (3 given)
37 >>> call2d(d)
38 Traceback (most recent call last):
39 TypeError: d() got an unexpected keyword argument 'd'
41 >>> call0abc(e)
42 1 2 3 []
43 >>> call2(e)
44 1 2 88 []
45 >>> call2c(e)
46 1 2 1 []
47 >>> call2d(e)
48 1 2 88 [('d', 1)]
49 >>> call2cde(e)
50 1 2 1 [('d', 2), ('e', 3)]
51 >>> call3(e)
52 1 2 3 []
53 >>> call4(e)
54 Traceback (most recent call last):
55 TypeError: e() takes at most 3 positional arguments (4 given)
57 >>> call0abc(f)
58 1 2 3 42
59 >>> call2c(f)
60 1 2 1 42
61 >>> call2cd(f)
62 1 2 1 2
64 >>> call3(f)
65 Traceback (most recent call last):
66 TypeError: f() takes exactly 2 positional arguments (3 given)
67 >>> call2(f)
68 Traceback (most recent call last):
69 TypeError: f() needs keyword-only argument c
70 >>> call2ce(f)
71 Traceback (most recent call last):
72 TypeError: f() got an unexpected keyword argument 'e'
74 >>> call2cf(g)
75 1 2 1 42 17 2 []
76 >>> call2cefd(g)
77 1 2 1 11 0 2 []
78 >>> call2cfex(g)
79 1 2 1 42 0 2 [('x', 25)]
81 >>> call3(g)
82 Traceback (most recent call last):
83 TypeError: g() takes exactly 2 positional arguments (3 given)
84 >>> call2(g)
85 Traceback (most recent call last):
86 TypeError: g() needs keyword-only argument c
87 >>> call2c(g)
88 Traceback (most recent call last):
89 TypeError: g() needs keyword-only argument f
91 >>> call2cf(h)
92 1 2 1 42 17 2 () []
93 >>> call2cfe(h)
94 1 2 1 42 3 2 () []
95 >>> call6cf(h)
96 1 2 1 42 17 2 (3, 4, 5, 6) []
97 >>> call6cfexy(h)
98 1 2 1 42 3 2 (3, 4, 5, 6) [('x', 25), ('y', 11)]
100 >>> call3(h)
101 Traceback (most recent call last):
102 TypeError: h() needs keyword-only argument c
103 >>> call3d(h)
104 Traceback (most recent call last):
105 TypeError: h() needs keyword-only argument c
107 >>> call2cf(k)
108 1 2 1 42 17 2 () []
109 >>> call2cfe(k)
110 1 2 1 42 3 2 () []
111 >>> call6df(k)
112 1 2 3 1 17 2 (4, 5, 6) []
113 >>> call6dfexy(k)
114 1 2 3 1 3 2 (4, 5, 6) [('x', 25), ('y', 11)]
116 >>> call3(k)
117 Traceback (most recent call last):
118 TypeError: k() needs keyword-only argument f
119 >>> call2d(k)
120 Traceback (most recent call last):
121 TypeError: k() needs keyword-only argument f
123 >>> call0abc(m)
124 1 2 3
125 >>> call2c(m)
126 1 2 1
128 >>> call3(m)
129 Traceback (most recent call last):
130 TypeError: m() takes at most 2 positional arguments (3 given)
131 >>> call2(m)
132 Traceback (most recent call last):
133 TypeError: m() needs keyword-only argument c
134 >>> call2cd(m)
135 Traceback (most recent call last):
136 TypeError: m() got an unexpected keyword argument 'd'
137 """
139 # the calls:
141 def call0ab(f):
142 f(a=1,b=2)
144 def call0abc(f):
145 f(a=1,b=2,c=3)
147 def call2(f):
148 f(1,2)
150 def call3(f):
151 f(1,2,3)
153 def call4(f):
154 f(1,2,3,4)
156 def call2c(f):
157 f(1,2, c=1)
159 def call2d(f):
160 f(1,2, d=1)
162 def call3d(f):
163 f(1,2,3, d=1)
165 def call2cd(f):
166 f(1,2, c=1, d=2)
168 def call2ce(f):
169 f(1,2, c=1, e=2)
171 def call2cde(f):
172 f(1,2, c=1, d=2, e=3)
174 def call2cf(f):
175 f(1,2, c=1, f=2)
177 def call6cf(f):
178 f(1,2,3,4,5,6, c=1, f=2)
180 def call6df(f):
181 f(1,2,3,4,5,6, d=1, f=2)
183 def call2cfe(f):
184 f(1,2, c=1, f=2, e=3)
186 def call2cefd(f):
187 f(1,2, c=1, e=0, f=2, d=11)
189 def call2cfex(f):
190 f(1,2, c=1, f=2, e=0, x=25)
192 def call6argscfexy(f):
193 args = (1,2,3,4,5,6)
194 f(*args, c=1, f=2, e=3, x=25, y=11)
196 def call6cfexy(f):
197 f(1,2,3,4,5,6, c=1, f=2, e=3, x=25, y=11)
199 def call6dfexy(f):
200 f(1,2,3,4,5,6, d=1, f=2, e=3, x=25, y=11)
202 # the called functions:
204 def b(a, b, c):
205 print a,b,c
207 def c(a, b, c=1):
208 print a,b,c
210 def d(a, b, *, c = 88):
211 print a,b,c
213 def e(a, b, c = 88, **kwds):
214 kwlist = list(kwds.items())
215 kwlist.sort()
216 print a,b,c, kwlist
218 def f(a, b, *, c, d = 42):
219 print a,b,c,d
221 def g(a, b, *, c, d = 42, e = 17, f, **kwds):
222 kwlist = list(kwds.items())
223 kwlist.sort()
224 print a,b,c,d,e,f, kwlist
226 def h(a, b, *args, c, d = 42, e = 17, f, **kwds):
227 kwlist = list(kwds.items())
228 kwlist.sort()
229 print a,b,c,d,e,f, args, kwlist
231 def k(a, b, c=1, *args, d = 42, e = 17, f, **kwds):
232 kwlist = list(kwds.items())
233 kwlist.sort()
234 print a,b,c,d,e,f, args, kwlist
236 def m(a, b=1, *, c):
237 print a,b,c