1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
def test1():
"""
>>> test1()
2
"""
cdef int[2][2] x
x[0][0] = 1
x[0][1] = 2
x[1][0] = 3
x[1][1] = 4
return f(x)[1]
cdef int* f(int x[2][2]):
return x[0]
def assign_index_in_loop():
"""
>>> assign_index_in_loop()
2
"""
cdef int i = 0
cdef int[1] a
cdef int[1] b
for a[0], b[0] in enumerate(range(3)):
assert a[0] == b[0]
assert a[0] == i
i += 1
assert a[0] == b[0]
return b[0]
def test2():
"""
>>> test2()
0
"""
cdef int[5] a1
cdef int a2[2+3]
return sizeof(a1) - sizeof(a2)
cdef enum:
MY_SIZE_A = 2
MY_SIZE_B = 3
def test3():
"""
>>> test3()
(2, 3)
"""
cdef int a[MY_SIZE_A]
cdef int b[MY_SIZE_B]
return sizeof(a)/sizeof(int), sizeof(b)/sizeof(int)
from libc cimport limits
def test_cimported_attribute():
"""
>>> test_cimported_attribute()
True
"""
cdef char a[limits.CHAR_MAX]
return sizeof(a) >= 127
|