Cython has moved to github.

cython-devel

view tests/run/literal_lists.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
children 0310198e281e
line source
1 __doc__ = """
2 >>> test_ints(100)
3 (100, 100, 100)
4 >>> test_chars("yo")
5 ('a', 'bc', 'yo')
6 >>> test_chars(None)
7 Traceback (most recent call last):
8 ...
9 TypeError: expected string or Unicode object, NoneType found
10 >>> test_struct(-5, -10)
11 -5 -10 True
12 1 2 False
13 """
15 def test_ints(int x):
16 cdef list L = [1,2,3,x]
17 cdef int* Li = [1,2,3,x]
18 cdef int** Lii = [Li, &x]
19 return L[3], Li[3], Lii[1][0]
21 def test_chars(foo):
22 cdef char** ss = ["a", "bc", foo]
23 return ss[0], ss[1], ss[2]
25 cdef struct MyStruct:
26 int x
27 int y
28 double** data
30 cdef print_struct(MyStruct a):
31 print a.x, a.y, a.data == NULL
33 def test_struct(int x, y):
34 cdef MyStruct* aa = [[x,y, NULL], [x+1,y+1,NULL]]
35 print_struct(aa[0])
36 print_struct([1, 2, <double**>1])
38 # Make sure it's still naturally an object.
40 [0,1,2,3].append(4)