Cython has moved to github.

cython-devel

view tests/run/classkwonlyargs.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 a52d934eab4d
children
line source
1 __doc__ = u"""
2 >>> spam = Spam()
3 >>> b,c,d,e,f,g,h,k = spam.b,spam.c,spam.d,spam.e,spam.f,spam.g,spam.h,spam.k
5 >>> b(1,2,3)
6 >>> b(1,2,3,4)
7 Traceback (most recent call last):
8 TypeError: b() takes exactly 4 positional arguments (5 given)
10 >>> c(1,2)
11 >>> c(1,2,3)
12 >>> c(1,2,3,4)
13 Traceback (most recent call last):
14 TypeError: c() takes at most 4 positional arguments (5 given)
16 >>> d(1,2)
17 >>> d(1,2, c=1)
19 >>> d(1,2,3)
20 Traceback (most recent call last):
21 TypeError: d() takes exactly 3 positional arguments (4 given)
22 >>> d(1,2, d=1)
23 Traceback (most recent call last):
24 TypeError: d() got an unexpected keyword argument 'd'
26 >>> e(1,2)
27 >>> e(1,2, c=1)
28 >>> e(1,2, d=1)
29 >>> e(1,2, c=1, d=2, e=3)
30 >>> e(1,2,3)
31 >>> e(1,2,3,4)
32 Traceback (most recent call last):
33 TypeError: e() takes at most 4 positional arguments (5 given)
35 >>> f(1,2, c=1)
36 >>> f(1,2, c=1, d=2)
38 >>> f(1,2,3)
39 Traceback (most recent call last):
40 TypeError: f() takes exactly 3 positional arguments (4 given)
41 >>> f(1,2)
42 Traceback (most recent call last):
43 TypeError: f() needs keyword-only argument c
44 >>> f(1,2, c=1, e=2)
45 Traceback (most recent call last):
46 TypeError: f() got an unexpected keyword argument 'e'
48 >>> g(1,2, c=1, f=2)
49 >>> g(1,2, c=1, e=0, f=2, d=11)
50 >>> g(1,2, c=1, f=2, e=0, x=25)
52 >>> g(1,2,3)
53 Traceback (most recent call last):
54 TypeError: g() takes exactly 3 positional arguments (4 given)
55 >>> g(1,2)
56 Traceback (most recent call last):
57 TypeError: g() needs keyword-only argument c
58 >>> g(1,2, c=1)
59 Traceback (most recent call last):
60 TypeError: g() needs keyword-only argument f
62 >>> h(1,2, c=1, f=2)
63 >>> h(1,2, c=1, f=2, e=3)
64 >>> h(1,2,3,4,5,6, c=1, f=2)
65 >>> h(1,2,3,4,5,6, c=1, f=2, e=3, x=25, y=11)
67 >>> h(1,2,3)
68 Traceback (most recent call last):
69 TypeError: h() needs keyword-only argument c
70 >>> h(1,2, d=1)
71 Traceback (most recent call last):
72 TypeError: h() needs keyword-only argument c
74 >>> k(1,2, c=1, f=2)
75 >>> k(1,2, c=1, f=2, e=3)
76 >>> k(1,2,3,4,5,6, d=1, f=2)
77 >>> k(1,2,3,4,5,6, d=1, f=2, e=3, x=25, y=11)
79 >>> k(1,2,3)
80 Traceback (most recent call last):
81 TypeError: k() needs keyword-only argument f
82 >>> k(1,2, d=1)
83 Traceback (most recent call last):
84 TypeError: k() needs keyword-only argument f
85 """
87 class Spam:
88 def b(self, a, b, c):
89 pass
91 def c(self, a, b, c=1):
92 pass
94 def d(self, a, b, *, c = 88):
95 pass
97 def e(self, a, b, c = 88, **kwds):
98 pass
100 def f(self, a, b, *, c, d = 42):
101 pass
103 def g(self, a, b, *, c, d = 42, e = 17, f, **kwds):
104 pass
106 def h(self, a, b, *args, c, d = 42, e = 17, f, **kwds):
107 pass
109 def k(self, a, b, c=1, *args, d = 42, e = 17, f, **kwds):
110 pass