Cython has moved to github.
cython-devel
view tests/run/slice3.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 | 6309e21af543 |
| children | 1dadfbd04642 |
line source
1 __doc__ = u"""
2 >>> class Test(object):
3 ... def __setitem__(self, key, value):
4 ... print((key, value))
5 ... def __getitem__(self, key):
6 ... print(key)
7 ... return self
9 >>> ellipsis(Test())
10 Ellipsis
12 >>> full(Test())
13 slice(None, None, None)
15 >>> select(0, Test(), 10, 20, 30)
16 slice(10, None, None)
17 slice(None, 20, None)
18 slice(None, None, 30)
19 slice(10, 20, None)
20 slice(10, None, 30)
21 slice(None, 20, 30)
22 slice(10, 20, 30)
23 slice(1, 2, 3)
25 >>> set(Test(), -11)
26 (slice(1, 2, 3), -11)
27 """
29 def ellipsis(o):
30 obj1 = o[...]
32 def full(o):
33 obj1 = o[::]
35 def set(o, v):
36 cdef int int3, int4, int5
37 int3, int4, int5 = 1,2,3
38 o[int3:int4:int5] = v
40 def select(obj1, obj2, obj3, obj4, obj5):
41 cdef int int3, int4, int5
42 int3, int4, int5 = 1,2,3
44 obj1 = obj2[obj3::]
45 obj1 = obj2[:obj4:]
46 obj1 = obj2[::obj5]
47 obj1 = obj2[obj3:obj4:]
48 obj1 = obj2[obj3::obj5]
49 obj1 = obj2[:obj4:obj5]
50 obj1 = obj2[obj3:obj4:obj5]
51 obj1 = obj2[int3:int4:int5]
