Commit 7a787e18 authored by Robert Bradshaw's avatar Robert Bradshaw

Move declarators in tests.

parent aa0d6c56
......@@ -6,7 +6,7 @@ cdef enum E:
cdef void f():
cdef int *p
cdef void *v
cdef int a[5]
cdef int[5] a
cdef int i=0
cdef E e=z
p = a
......
......@@ -10,7 +10,7 @@ cdef class Spam:
cdef public float f
cdef public double d
cdef public char *s
cdef readonly char a[42]
cdef readonly char[42] a
cdef public object o
cdef readonly int r
cdef readonly Spam e
......@@ -3,7 +3,7 @@
def f(obj1, obj2, obj3):
cdef int int1, int2=0, int3=0
cdef float flt1, *ptr1=NULL
cdef int array1[42]
cdef int[42] array1
array1[int2] = 0
int1 = array1[int2]
flt1 = ptr1[int2]
......
......@@ -7,7 +7,7 @@ def test():
cdef int i = 1, j = 2, k = 3
cdef float x = 1, y = 2, z = 3
cdef object a = 1, b = 2, c = 3, d = 4, e = 5
cdef int m[3]
cdef int[3] m
m[0] = 0
m[1] = 1
m[2] = 1
......
......@@ -4,7 +4,7 @@ cdef extern from "string.h":
void memcpy(void* des, void* src, int size)
cdef void f():
cdef float f1[3]
cdef float[3] f1
cdef float* f2
f2 = f1 + 1
memcpy(f1, f2, 1)
......
# mode: compile
cdef class T:
cdef int a[1]
cdef int[1] a
cdef object b
......
......@@ -50,7 +50,7 @@ baz[0] = d
cdef int *baz
print var[0][0]
cdef unsigned long long var[100][100]
cdef unsigned long long[100][100] var
# in 0.11.1 these are warnings
FUTURE_ERRORS = u"""
......
......@@ -184,7 +184,7 @@ def test_cyarray_from_carray():
0 8 21
0 8 21
"""
cdef int a[7][8]
cdef int[7][8] a
for i in range(7):
for j in range(8):
a[i][j] = i * 8 + j
......
......@@ -958,7 +958,7 @@ def test_contig_scalar_to_slice_assignment():
14 14 14 14
20 20 20 20
"""
cdef int a[5][10]
cdef int[5][10] a
cdef int[:, ::1] _m = a
m = _m
......
......@@ -1322,7 +1322,7 @@ cdef class TestIndexSlicingDirectIndirectDims(object):
cdef Py_ssize_t[3] shape, strides, suboffsets
cdef int c_array[5]
cdef int[5] c_array
cdef int *myarray[5][5]
cdef bytes format
......@@ -1647,8 +1647,8 @@ def test_memslice_struct_with_arrays():
abc
abc
"""
cdef ArrayStruct a1[10]
cdef PackedArrayStruct a2[10]
cdef ArrayStruct[10] a1
cdef PackedArrayStruct[10] a2
test_structs_with_arr(a1)
test_structs_with_arr(a2)
......@@ -1760,14 +1760,14 @@ def test_padded_structs():
"""
>>> test_padded_structs()
"""
cdef ArrayStruct a1[10]
cdef PackedArrayStruct a2[10]
cdef AlignedNested a3[10]
cdef AlignedNestedNormal a4[10]
cdef A a5[10]
cdef B a6[10]
cdef C a7[10]
cdef D a8[10]
cdef ArrayStruct[10] a1
cdef PackedArrayStruct[10] a2
cdef AlignedNested[10] a3
cdef AlignedNestedNormal[10] a4
cdef A[10] a5
cdef B[10] a6
cdef C[10] a7
cdef D[10] a8
_test_padded(a1)
_test_padded(a2)
......@@ -1794,7 +1794,7 @@ def test_object_indices():
1
2
"""
cdef int array[3]
cdef int[3] array
cdef int[:] myslice = array
cdef int j
......@@ -1835,7 +1835,7 @@ def test_slice_assignment():
"""
>>> test_slice_assignment()
"""
cdef int carray[10][100]
cdef int[10][100] carray
cdef int i, j
for i in range(10):
......@@ -1864,8 +1864,8 @@ def test_slice_assignment_broadcast_leading():
"""
>>> test_slice_assignment_broadcast_leading()
"""
cdef int array1[1][10]
cdef int array2[10]
cdef int[1][10] array1
cdef int[10] array2
cdef int i
for i in range(10):
......@@ -1896,8 +1896,8 @@ def test_slice_assignment_broadcast_strides():
"""
>>> test_slice_assignment_broadcast_strides()
"""
cdef int src_array[10]
cdef int dst_array[10][5]
cdef int[10] src_array
cdef int[10][5] dst_array
cdef int i, j
for i in range(10):
......@@ -2046,7 +2046,7 @@ def test_scalar_slice_assignment():
cdef int[10] a
cdef int[:] m = a
cdef int a2[5][10]
cdef int[5][10] a2
cdef int[:, ::1] m2 = a2
_test_scalar_slice_assignment(m, m2)
......@@ -2102,7 +2102,7 @@ def test_contig_scalar_to_slice_assignment():
14 14 14 14
20 20 20 20
"""
cdef int a[5][10]
cdef int[5][10] a
cdef int[:, ::1] m = a
m[...] = 14
......
......@@ -296,28 +296,28 @@ def test_coerce_to_numpy():
#
### First set up some C arrays that will be used to hold data
#
cdef MyStruct mystructs[20]
cdef SmallStruct smallstructs[20]
cdef NestedStruct nestedstructs[20]
cdef PackedStruct packedstructs[20]
cdef MyStruct[20] mystructs
cdef SmallStruct[20] smallstructs
cdef NestedStruct[20] nestedstructs
cdef PackedStruct[20] packedstructs
cdef signed char chars[20]
cdef short shorts[20]
cdef int ints[20]
cdef long long longlongs[20]
cdef td_h_short externs[20]
cdef signed char[20] chars
cdef short[20] shorts
cdef int[20] ints
cdef long long[20] longlongs
cdef td_h_short[20] externs
cdef float floats[20]
cdef double doubles[20]
cdef long double longdoubles[20]
cdef float[20] floats
cdef double[20] doubles
cdef long double[20] longdoubles
cdef float complex floatcomplex[20]
cdef double complex doublecomplex[20]
cdef long double complex longdoublecomplex[20]
cdef float complex[20] floatcomplex
cdef double complex[20] doublecomplex
cdef long double complex[20] longdoublecomplex
cdef td_h_short h_shorts[20]
cdef td_h_double h_doubles[20]
cdef td_h_ushort h_ushorts[20]
cdef td_h_short[20] h_shorts
cdef td_h_double[20] h_doubles
cdef td_h_ushort[20] h_ushorts
cdef Py_ssize_t idx = 17
......@@ -586,7 +586,7 @@ cdef getbuffer(Buffer self, Py_buffer *info):
info.format = self.format
cdef class Buffer(object):
cdef Py_ssize_t _shape[2]
cdef Py_ssize_t[2] _shape
cdef bytes format
cdef float[:, :] m
cdef object shape, strides
......
......@@ -153,7 +153,7 @@ def slice_charptr_for_loop_c_enumerate():
############################################################
# tests for int* slicing
cdef int cints[6]
cdef int[6] cints
for i in range(6):
cints[i] = i
......@@ -207,7 +207,7 @@ def slice_intptr_for_loop_c():
############################################################
# tests for slicing other arrays
cdef double cdoubles[6]
cdef double[6] cdoubles
for i in range(6):
cdoubles[i] = i + 0.5
......@@ -267,7 +267,7 @@ def struct_ptr_iter():
>>> struct_ptr_iter()
([0, 1, 2, 3, 4], [0, 1, 2, 3, 4], [0, 1, 2, 3, 4])
"""
cdef MyStruct my_structs[5]
cdef MyStruct[5] my_structs
for i in range(5):
my_structs[i].i = i
cdef MyStruct value
......
......@@ -3,7 +3,7 @@ def test1():
>>> test1()
2
"""
cdef int x[2][2]
cdef int[2][2] x
x[0][0] = 1
x[0][1] = 2
x[1][0] = 3
......@@ -19,7 +19,7 @@ def test2():
>>> test2()
0
"""
cdef int a1[5]
cdef int[5] a1
cdef int a2[2+3]
return sizeof(a1) - sizeof(a2)
......
......@@ -195,7 +195,7 @@ def varargs():
>>> print(varargs())
abc
"""
cdef char buffer[10]
cdef char[10] buffer
retval = snprintf(buffer, template="abc", size=10)
if retval < 0:
raise MemoryError()
......
......@@ -7,7 +7,8 @@ def test(x, int y):
"""
if True:
before = 0
cdef int a = 4, b = x, c = y, *p = &y
cdef int a = 4, b = x, c = y
cdef int *p = &y
cdef object o = int(8)
print a, b, c, p[0], before, g, o
......
......@@ -23,7 +23,7 @@ else:
"""
def test_assign():
cdef char s[17]
cdef char[17] s
s[ 0] = c'\x10'
s[ 1] = c'\x21'
......
......@@ -11,7 +11,7 @@ else:
"""
def test():
cdef char s[50]
cdef char[50] s
s[ 0] = c'\0'
s[ 1] = c'\x01'
......
......@@ -16,7 +16,7 @@ def eggs():
>>> print(str(eggs()).replace("b'", "'"))
('abcdefg', 'abcdefg')
"""
cdef char silly[42]
cdef char[42] silly
cdef Grail grail
spam(silly)
spam(grail.silly)
......
......@@ -83,7 +83,7 @@ def test_copy(char *a):
True
"""
cdef string t = string(a)
cdef char buffer[6]
cdef char[6] buffer
cdef size_t length = t.copy(buffer, 4, 1)
buffer[length] = c'\0'
return buffer
......
......@@ -15,8 +15,8 @@ def f():
cdef char *a_char_ptr, *another_char_ptr
cdef char **a_char_ptr_ptr
cdef char ***a_char_ptr_ptr_ptr
cdef char a_sized_char_array[10]
cdef char a_2d_char_array[10][20]
cdef char[10] a_sized_char_array
cdef char[10][20] a_2d_char_array
cdef char *a_2d_char_ptr_array[10][20]
cdef char **a_2d_char_ptr_ptr_array[10][20]
cdef int (*a_0arg_function)()
......
......@@ -9,7 +9,7 @@ def libc_cimports():
>>> libc_cimports()
hello
"""
cdef char buf[10]
cdef char[10] buf
sprintf(buf, "%s", b'hello')
print (<object>buf).decode('ASCII')
......
......@@ -3,6 +3,6 @@ def test():
>>> test()
1.0
"""
cdef float v[10][10]
cdef float[10][10] v
v[1][2] = 1.0
return v[1][2]
......@@ -62,7 +62,7 @@ def c_enumerate_carray_target():
3 4
"""
cdef int k
cdef int i[1]
cdef int[1] i
for i[0],k in enumerate(range(1,5)):
print i[0], k
......
......@@ -94,10 +94,10 @@ def test_fused_with_pointer():
breakfast
humptydumptyfallsplatchbreakfast
"""
cdef int int_array[5]
cdef long long_array[5]
cdef float float_array[5]
cdef string_t string_array[5]
cdef int[5] int_array
cdef long[5] long_array
cdef float[5] float_array
cdef string_t[5] string_array
cdef char *s
......
......@@ -111,7 +111,7 @@ def test_side_effects():
a[side_effect(1)] += 10
a[c_side_effect(2)] += 100
cdef int i
cdef int b[5]
cdef int[5] b
for i from 0 <= i < 5:
b[i] = i
b[side_effect(3)] += 10
......
......@@ -9,7 +9,7 @@ __doc__ = u"""
"""
cdef class A:
cdef double x[3]
cdef double[3] x
def __init__(self, *args):
cdef int i, max
......
cdef int data[10]
cdef int[10] data
cdef int[:] myslice = data
def test_memoryview_namespace():
......
......@@ -17,7 +17,7 @@ ctypedef Py_UNICODE* LPWSTR
cdef unicode uobj = u'unicode\u1234'
cdef unicode uobj1 = u'u'
cdef Py_UNICODE* c_pu_str = u"unicode\u1234"
cdef Py_UNICODE c_pu_arr[42]
cdef Py_UNICODE[42] c_pu_arr
cdef LPWSTR c_wstr = u"unicode\u1234"
cdef Py_UNICODE* c_pu_empty = u""
cdef char* c_empty = ""
......
......@@ -4,7 +4,7 @@ def primes(int kmax):
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]
"""
cdef int n, k, i
cdef int p[1000]
cdef int[1000] p
result = []
if kmax > 1000:
kmax = 1000
......
......@@ -14,6 +14,6 @@ cdef extern from "string.h":
from cpython cimport PyUnicode_DecodeUTF8
def spam():
cdef char buf[12]
cdef char[12] buf
memcpy(buf, "Ftang\0Ftang!", sizeof(buf))
return PyUnicode_DecodeUTF8(buf, sizeof(buf), NULL)
......@@ -25,7 +25,7 @@ def nonzero(int x):
from libc.string cimport strcpy
cdef char error_msg[256]
cdef char[256] error_msg
cdef jmp_buf error_ctx
cdef void error(char msg[]) nogil:
strcpy(error_msg,msg)
......
......@@ -385,7 +385,7 @@ def loop_over_struct_ptr():
>>> print( loop_over_struct_ptr() )
MyStruct
"""
cdef MyStruct a_list[10]
cdef MyStruct[10] a_list
cdef MyStruct *a_ptr = a_list
for i in a_list[:10]:
pass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment