cython-devel
diff tests/run/arrayassign.pyx @ 4256:b816b03ff502
Make __new__ -> __cinit__ into an error, fix compiler crash.
| author | Robert Bradshaw <robertwb@math.washington.edu> |
|---|---|
| date | Tue Dec 21 02:09:22 2010 -0800 (17 months ago) |
| parents | 41d2107a2074 |
| children |
line diff
1.1 --- a/tests/run/arrayassign.pyx Fri Nov 14 19:20:43 2008 +0100
1.2 +++ b/tests/run/arrayassign.pyx Tue Dec 21 02:09:22 2010 -0800
1.3 @@ -1,60 +1,3 @@
1.4 -__doc__ = u"""
1.5 ->>> test_literal_list_slice_all()
1.6 -(1, 2, 3, 4, 5)
1.7 ->>> test_literal_list_slice_start()
1.8 -(1, 2, 3, 4, 5)
1.9 ->>> test_literal_list_slice_end()
1.10 -(1, 2, 3, 4, 5)
1.11 ->>> test_literal_list_slice_start_end()
1.12 -(1, 2, 3, 4, 5)
1.13 -
1.14 ->>> test_literal_list_slice_start_param(4)
1.15 -(1, 2, 3, 4, 5)
1.16 ->>> test_literal_list_slice_start_param(3)
1.17 -Traceback (most recent call last):
1.18 -ValueError: Assignment to slice of wrong length, expected 5, got 6
1.19 ->>> test_literal_list_slice_start_param(5)
1.20 -Traceback (most recent call last):
1.21 -ValueError: Assignment to slice of wrong length, expected 5, got 4
1.22 -
1.23 ->>> test_literal_list_slice_end_param(5)
1.24 -(1, 2, 3, 4, 5)
1.25 ->>> test_literal_list_slice_end_param(4)
1.26 -Traceback (most recent call last):
1.27 -ValueError: Assignment to slice of wrong length, expected 5, got 4
1.28 ->>> test_literal_list_slice_end_param(6)
1.29 -Traceback (most recent call last):
1.30 -ValueError: Assignment to slice of wrong length, expected 5, got 6
1.31 -
1.32 ->>> test_literal_list_slice_start_end_param(2,7)
1.33 -(1, 2, 3, 4, 5)
1.34 ->>> test_literal_list_slice_start_end_param(3,7)
1.35 -Traceback (most recent call last):
1.36 -ValueError: Assignment to slice of wrong length, expected 5, got 4
1.37 ->>> test_literal_list_slice_start_end_param(1,7)
1.38 -Traceback (most recent call last):
1.39 -ValueError: Assignment to slice of wrong length, expected 5, got 6
1.40 ->>> test_literal_list_slice_start_end_param(2,6)
1.41 -Traceback (most recent call last):
1.42 -ValueError: Assignment to slice of wrong length, expected 5, got 4
1.43 ->>> test_literal_list_slice_start_end_param(2,8)
1.44 -Traceback (most recent call last):
1.45 -ValueError: Assignment to slice of wrong length, expected 5, got 6
1.46 ->>> test_literal_list_slice_start_end_param(3,6)
1.47 -Traceback (most recent call last):
1.48 -ValueError: Assignment to slice of wrong length, expected 5, got 3
1.49 ->>> test_literal_list_slice_start_end_param(1,8)
1.50 -Traceback (most recent call last):
1.51 -ValueError: Assignment to slice of wrong length, expected 5, got 7
1.52 -
1.53 ->>> test_ptr_literal_list_slice_all()
1.54 -(1, 2, 3, 4, 5)
1.55 ->>> test_ptr_literal_list_slice_start()
1.56 -(1, 2, 3, 4, 5)
1.57 ->>> test_ptr_literal_list_slice_end()
1.58 -(1, 2, 3, 4, 5)
1.59 -"""
1.60 -
1.61 # this doesn't work - it would reassign the array address!
1.62 #
1.63 #def test_literal_list():
1.64 @@ -63,54 +6,124 @@
1.65 # return (a[0], a[1], a[2], a[3], a[4])
1.66
1.67 def test_literal_list_slice_all():
1.68 + """
1.69 + >>> test_literal_list_slice_all()
1.70 + (1, 2, 3, 4, 5)
1.71 + """
1.72 cdef int a[5] # = [5,4,3,2,1]
1.73 a[:] = [1,2,3,4,5]
1.74 return (a[0], a[1], a[2], a[3], a[4])
1.75
1.76 def test_literal_list_slice_start():
1.77 + """
1.78 + >>> test_literal_list_slice_start()
1.79 + (1, 2, 3, 4, 5)
1.80 + """
1.81 cdef int a[7] # = [7,6,5,4,3,2,1]
1.82 a[2:] = [1,2,3,4,5]
1.83 return (a[2], a[3], a[4], a[5], a[6])
1.84
1.85 def test_literal_list_slice_end():
1.86 + """
1.87 + >>> test_literal_list_slice_end()
1.88 + (1, 2, 3, 4, 5)
1.89 + """
1.90 cdef int a[7] # = [7,6,5,4,3,2,1]
1.91 a[:5] = [1,2,3,4,5]
1.92 return (a[0], a[1], a[2], a[3], a[4])
1.93
1.94 def test_literal_list_slice_start_end():
1.95 + """
1.96 + >>> test_literal_list_slice_start_end()
1.97 + (1, 2, 3, 4, 5)
1.98 + """
1.99 cdef int a[9] # = [9,8,7,6,5,4,3,2,1]
1.100 a[2:7] = [1,2,3,4,5]
1.101 return (a[2], a[3], a[4], a[5], a[6])
1.102
1.103 def test_literal_list_slice_start_param(s):
1.104 + """
1.105 + >>> test_literal_list_slice_start_param(4)
1.106 + (1, 2, 3, 4, 5)
1.107 + >>> test_literal_list_slice_start_param(3)
1.108 + Traceback (most recent call last):
1.109 + ValueError: Assignment to slice of wrong length, expected 5, got 6
1.110 + >>> test_literal_list_slice_start_param(5)
1.111 + Traceback (most recent call last):
1.112 + ValueError: Assignment to slice of wrong length, expected 5, got 4
1.113 + """
1.114 cdef int a[9] # = [9,8,7,6,5,4,3,2,1]
1.115 a[s:] = [1,2,3,4,5]
1.116 return (a[4], a[5], a[6], a[7], a[8])
1.117 # return a[s:]
1.118
1.119 def test_literal_list_slice_end_param(e):
1.120 + """
1.121 + >>> test_literal_list_slice_end_param(5)
1.122 + (1, 2, 3, 4, 5)
1.123 + >>> test_literal_list_slice_end_param(4)
1.124 + Traceback (most recent call last):
1.125 + ValueError: Assignment to slice of wrong length, expected 5, got 4
1.126 + >>> test_literal_list_slice_end_param(6)
1.127 + Traceback (most recent call last):
1.128 + ValueError: Assignment to slice of wrong length, expected 5, got 6
1.129 + """
1.130 cdef int a[9] # = [9,8,7,6,5,4,3,2,1]
1.131 a[:e] = [1,2,3,4,5]
1.132 return (a[0], a[1], a[2], a[3], a[4])
1.133 # return a[:e]
1.134
1.135 def test_literal_list_slice_start_end_param(s,e):
1.136 + """
1.137 + >>> test_literal_list_slice_start_end_param(2,7)
1.138 + (1, 2, 3, 4, 5)
1.139 + >>> test_literal_list_slice_start_end_param(3,7)
1.140 + Traceback (most recent call last):
1.141 + ValueError: Assignment to slice of wrong length, expected 5, got 4
1.142 + >>> test_literal_list_slice_start_end_param(1,7)
1.143 + Traceback (most recent call last):
1.144 + ValueError: Assignment to slice of wrong length, expected 5, got 6
1.145 + >>> test_literal_list_slice_start_end_param(2,6)
1.146 + Traceback (most recent call last):
1.147 + ValueError: Assignment to slice of wrong length, expected 5, got 4
1.148 + >>> test_literal_list_slice_start_end_param(2,8)
1.149 + Traceback (most recent call last):
1.150 + ValueError: Assignment to slice of wrong length, expected 5, got 6
1.151 + >>> test_literal_list_slice_start_end_param(3,6)
1.152 + Traceback (most recent call last):
1.153 + ValueError: Assignment to slice of wrong length, expected 5, got 3
1.154 + >>> test_literal_list_slice_start_end_param(1,8)
1.155 + Traceback (most recent call last):
1.156 + ValueError: Assignment to slice of wrong length, expected 5, got 7
1.157 + """
1.158 cdef int a[9] # = [9,8,7,6,5,4,3,2,1]
1.159 a[s:e] = [1,2,3,4,5]
1.160 return (a[2], a[3], a[4], a[5], a[6])
1.161 # return a[s:e]
1.162
1.163 def test_ptr_literal_list_slice_all():
1.164 + """
1.165 + >>> test_ptr_literal_list_slice_all()
1.166 + (1, 2, 3, 4, 5)
1.167 + """
1.168 cdef int *a = [6,5,4,3,2]
1.169 a[:] = [1,2,3,4,5]
1.170 return (a[0], a[1], a[2], a[3], a[4])
1.171
1.172 def test_ptr_literal_list_slice_start():
1.173 + """
1.174 + >>> test_ptr_literal_list_slice_start()
1.175 + (1, 2, 3, 4, 5)
1.176 + """
1.177 cdef int *a = [6,5,4,3,2,1]
1.178 a[1:] = [1,2,3,4,5]
1.179 return (a[1], a[2], a[3], a[4], a[5])
1.180
1.181 def test_ptr_literal_list_slice_end():
1.182 + """
1.183 + >>> test_ptr_literal_list_slice_end()
1.184 + (1, 2, 3, 4, 5)
1.185 + """
1.186 cdef int *a = [6,5,4,3,2,1]
1.187 a[:5] = [1,2,3,4,5]
1.188 return (a[0], a[1], a[2], a[3], a[4])
