Cython has moved to github.

cython-devel

view tests/run/ct_DEF.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 39f96a21ea14
children 9df9c698e2b9
line source
1 __doc__ = u"""
2 >>> c()
3 120
4 >>> i0() == -1
5 True
6 >>> i1() == 42
7 True
8 >>> i2() == 0x42
9 True
10 >>> i3() == 042
11 True
12 >>> i4() == -0x42
13 True
14 >>> l()
15 666
16 >>> f()
17 12.5
18 >>> s()
19 b'spam'
20 >>> two()
21 2
22 >>> five()
23 5
24 >>> true()
25 True
26 >>> false()
27 False
28 """
30 import sys
31 if sys.version_info[0] < 3:
32 __doc__ = __doc__.replace(u" b'", u" '")
34 import sys
35 if sys.version_info[0] >= 3:
36 __doc__ = __doc__.replace(u" 042", u" 0o42")
38 DEF TUPLE = (1, 2, u"buckle my shoe")
39 DEF TRUE_FALSE = (True, False)
41 DEF CHAR = c'x'
42 DEF INT0 = -1
43 DEF INT1 = 42
44 DEF INT2 = 0x42
45 DEF INT3 = 042
46 DEF INT4 = -0x42
47 DEF LONG = 666L
48 DEF FLOAT = 12.5
49 DEF STR = "spam"
50 DEF TWO = TUPLE[1]
51 DEF FIVE = TWO + 3
52 DEF TRUE = TRUE_FALSE[0]
53 DEF FALSE = TRUE_FALSE[1]
54 DEF INT_TUPLE1 = TUPLE[:2]
55 DEF INT_TUPLE2 = TUPLE[1:4:2]
57 def c():
58 cdef char c
59 c = CHAR
60 return c
62 def i0():
63 cdef int i
64 i = INT0
65 return i
67 def i1():
68 cdef int i
69 i = INT1
70 return i
72 def i2():
73 cdef int i
74 i = INT2
75 return i
77 def i3():
78 cdef int i
79 i = INT3
80 return i
82 def i4():
83 cdef int i
84 i = INT4
85 return i
87 def l():
88 cdef long l
89 l = LONG
90 return l
92 def f():
93 cdef float f
94 f = FLOAT
95 return f
97 def s():
98 cdef char *s
99 s = STR
100 return s
102 # this does not work!
103 #def t():
104 # cdef object t
105 # t = TUPLE
106 # return t
108 def two():
109 cdef int two
110 two = TWO
111 return two
113 # this doesn't currently work!
114 #def two2():
115 # cdef int two
116 # two = INT_TUPLE1[-1]
117 # return two
119 def five():
120 cdef int five
121 five = FIVE
122 return five
124 def true():
125 cdef bint true
126 true = TRUE
127 return true
129 def false():
130 cdef bint false
131 false = FALSE
132 return false