@@ -19,87 +19,105 @@ def assertEqual(x, y):
1919 print ("" )
2020 print ("typecode '%s'" % (typ ,))
2121 if typ == 'u' :
22- # FIXME(sbinet): implement
23- print (" SKIP: NotImplemented" )
24- continue
25- if typ in "bhilqfd" :
22+ arr = array .array (typ , "?世界!" )
23+ if typ in "bhilq" :
2624 arr = array .array (typ , [- 1 , - 2 , - 3 , - 4 ])
2725 if typ in "BHILQ" :
2826 arr = array .array (typ , [+ 1 , + 2 , + 3 , + 4 ])
29- print (" array: %s" % (repr (arr ),))
27+ if typ in "fd" :
28+ arr = array .array (typ , [- 1.0 , - 2.0 , - 3.0 , - 4.0 ])
29+ print (" array: %s ## repr" % (repr (arr ),))
30+ print (" array: %s ## str" % (str (arr ),))
3031 print (" itemsize: %s" % (arr .itemsize ,))
3132 print (" typecode: %s" % (arr .typecode ,))
3233 print (" len: %s" % (len (arr ),))
3334 print (" arr[0]: %s" % (arr [0 ],))
3435 print (" arr[-1]: %s" % (arr [- 1 ],))
3536 try :
3637 arr [- 10 ]
37- print (" ERROR : expected an exception" )
38+ print (" ERROR1 : expected an exception" )
3839 except :
3940 print (" caught an exception [ok]" )
4041
4142 try :
4243 arr [10 ]
43- print (" ERROR : expected an exception" )
44+ print (" ERROR2 : expected an exception" )
4445 except :
4546 print (" caught an exception [ok]" )
4647 arr [- 2 ] = 33
48+ if typ in "fd" :
49+ arr [- 2 ] = 0.3
4750 print (" arr[-2]: %s" % (arr [- 2 ],))
4851
4952 try :
5053 arr [- 10 ] = 2
51- print (" ERROR : expected an exception" )
54+ print (" ERROR3 : expected an exception" )
5255 except :
5356 print (" caught an exception [ok]" )
5457
5558 if typ in "bhilqfd" :
5659 arr .extend ([- 5 ,- 6 ])
5760 if typ in "BHILQ" :
5861 arr .extend ([5 ,6 ])
62+ if typ == 'u' :
63+ arr .extend ("he" )
5964 print (" array: %s" % (repr (arr ),))
6065 print (" len: %s" % (len (arr ),))
6166
6267 if typ in "bhilqfd" :
6368 arr .append (- 7 )
6469 if typ in "BHILQ" :
6570 arr .append (7 )
71+ if typ == 'u' :
72+ arr .append ("l" )
6673 print (" array: %s" % (repr (arr ),))
6774 print (" len: %s" % (len (arr ),))
6875
6976 try :
7077 arr .append ()
71- print (" ERROR : expected an exception" )
78+ print (" ERROR4 : expected an exception" )
7279 except :
7380 print (" caught an exception [ok]" )
7481 try :
7582 arr .append ([])
76- print (" ERROR : expected an exception" )
83+ print (" ERROR5 : expected an exception" )
7784 except :
7885 print (" caught an exception [ok]" )
7986 try :
8087 arr .append (1 , 2 )
81- print (" ERROR : expected an exception" )
88+ print (" ERROR6 : expected an exception" )
8289 except :
8390 print (" caught an exception [ok]" )
8491 try :
8592 arr .append (None )
86- print (" ERROR : expected an exception" )
93+ print (" ERROR7 : expected an exception" )
8794 except :
8895 print (" caught an exception [ok]" )
8996
9097 try :
9198 arr .extend ()
92- print (" ERROR : expected an exception" )
99+ print (" ERROR8 : expected an exception" )
93100 except :
94101 print (" caught an exception [ok]" )
95102 try :
96103 arr .extend (None )
97- print (" ERROR : expected an exception" )
104+ print (" ERROR9 : expected an exception" )
98105 except :
99106 print (" caught an exception [ok]" )
100107 try :
101108 arr .extend ([1 ,None ])
102- print (" ERROR: expected an exception" )
109+ print (" ERROR10: expected an exception" )
110+ except :
111+ print (" caught an exception [ok]" )
112+ try :
113+ arr .extend (1 ,None )
114+ print (" ERROR11: expected an exception" )
115+ except :
116+ print (" caught an exception [ok]" )
117+
118+ try :
119+ arr [0 ] = object ()
120+ print (" ERROR12: expected an exception" )
103121 except :
104122 print (" caught an exception [ok]" )
105123 pass
@@ -108,55 +126,48 @@ def assertEqual(x, y):
108126print ("## testing array.array(...)" )
109127try :
110128 arr = array .array ()
111- print ("ERROR : expected an exception" )
129+ print ("ERROR1 : expected an exception" )
112130except :
113131 print ("caught an exception [ok]" )
114132
115133try :
116134 arr = array .array (b"d" )
117- print ("ERROR : expected an exception" )
135+ print ("ERROR2 : expected an exception" )
118136except :
119137 print ("caught an exception [ok]" )
120138
121139try :
122140 arr = array .array ("?" )
123- print ("ERROR : expected an exception" )
141+ print ("ERROR3 : expected an exception" )
124142except :
125143 print ("caught an exception [ok]" )
126144
127145try :
128146 arr = array .array ("dd" )
129- print ("ERROR : expected an exception" )
147+ print ("ERROR4 : expected an exception" )
130148except :
131149 print ("caught an exception [ok]" )
132150
133151try :
134152 arr = array .array ("d" , initializer = [1 ,2 ])
135- print ("ERROR : expected an exception" )
153+ print ("ERROR5 : expected an exception" )
136154except :
137155 print ("caught an exception [ok]" )
138156
139157try :
140158 arr = array .array ("d" , [1 ], [])
141- print ("ERROR : expected an exception" )
159+ print ("ERROR6 : expected an exception" )
142160except :
143161 print ("caught an exception [ok]" )
144162
145163try :
146164 arr = array .array ("d" , 1 )
147- print ("ERROR : expected an exception" )
165+ print ("ERROR7 : expected an exception" )
148166except :
149167 print ("caught an exception [ok]" )
150168
151169try :
152170 arr = array .array ("d" , ["a" ,"b" ])
153- print ("ERROR: expected an exception" )
154- except :
155- print ("caught an exception [ok]" )
156-
157- try :
158- ## FIXME(sbinet): implement it at some point.
159- arr = array .array ("u" )
160- print ("ERROR: expected an exception" )
171+ print ("ERROR8: expected an exception" )
161172except :
162173 print ("caught an exception [ok]" )
0 commit comments