Cython has moved to github.
cython-devel
view tests/run/setcomp.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 | b638811d14d0 |
| children | 109840788023 |
line source
1 __doc__ = u"""
2 >>> type(smoketest()) is not list
3 True
4 >>> type(smoketest()) is _set
5 True
7 >>> sorted(smoketest())
8 [0, 4, 8]
9 >>> list(typed())
10 [A, A, A]
11 >>> sorted(iterdict())
12 [1, 2, 3]
13 """
15 # Py2.3 doesn't have the set type, but Cython does :)
16 _set = set
18 def smoketest():
19 return {x*2 for x in range(5) if x % 2 == 0}
21 cdef class A:
22 def __repr__(self): return u"A"
23 def __richcmp__(one, other, op): return one is other
24 def __hash__(self): return id(self) % 65536
26 def typed():
27 cdef A obj
28 return {obj for obj in {A(), A(), A()}}
30 def iterdict():
31 cdef dict d = dict(a=1,b=2,c=3)
32 return {d[key] for key in d}
34 def sorted(it):
35 l = list(it)
36 l.sort()
37 return l
