@@ -19,87 +19,105 @@ def assertEqual(x, y):
19
19
print ("" )
20
20
print ("typecode '%s'" % (typ ,))
21
21
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" :
26
24
arr = array .array (typ , [- 1 , - 2 , - 3 , - 4 ])
27
25
if typ in "BHILQ" :
28
26
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 ),))
30
31
print (" itemsize: %s" % (arr .itemsize ,))
31
32
print (" typecode: %s" % (arr .typecode ,))
32
33
print (" len: %s" % (len (arr ),))
33
34
print (" arr[0]: %s" % (arr [0 ],))
34
35
print (" arr[-1]: %s" % (arr [- 1 ],))
35
36
try :
36
37
arr [- 10 ]
37
- print (" ERROR : expected an exception" )
38
+ print (" ERROR1 : expected an exception" )
38
39
except :
39
40
print (" caught an exception [ok]" )
40
41
41
42
try :
42
43
arr [10 ]
43
- print (" ERROR : expected an exception" )
44
+ print (" ERROR2 : expected an exception" )
44
45
except :
45
46
print (" caught an exception [ok]" )
46
47
arr [- 2 ] = 33
48
+ if typ in "fd" :
49
+ arr [- 2 ] = 0.3
47
50
print (" arr[-2]: %s" % (arr [- 2 ],))
48
51
49
52
try :
50
53
arr [- 10 ] = 2
51
- print (" ERROR : expected an exception" )
54
+ print (" ERROR3 : expected an exception" )
52
55
except :
53
56
print (" caught an exception [ok]" )
54
57
55
58
if typ in "bhilqfd" :
56
59
arr .extend ([- 5 ,- 6 ])
57
60
if typ in "BHILQ" :
58
61
arr .extend ([5 ,6 ])
62
+ if typ == 'u' :
63
+ arr .extend ("he" )
59
64
print (" array: %s" % (repr (arr ),))
60
65
print (" len: %s" % (len (arr ),))
61
66
62
67
if typ in "bhilqfd" :
63
68
arr .append (- 7 )
64
69
if typ in "BHILQ" :
65
70
arr .append (7 )
71
+ if typ == 'u' :
72
+ arr .append ("l" )
66
73
print (" array: %s" % (repr (arr ),))
67
74
print (" len: %s" % (len (arr ),))
68
75
69
76
try :
70
77
arr .append ()
71
- print (" ERROR : expected an exception" )
78
+ print (" ERROR4 : expected an exception" )
72
79
except :
73
80
print (" caught an exception [ok]" )
74
81
try :
75
82
arr .append ([])
76
- print (" ERROR : expected an exception" )
83
+ print (" ERROR5 : expected an exception" )
77
84
except :
78
85
print (" caught an exception [ok]" )
79
86
try :
80
87
arr .append (1 , 2 )
81
- print (" ERROR : expected an exception" )
88
+ print (" ERROR6 : expected an exception" )
82
89
except :
83
90
print (" caught an exception [ok]" )
84
91
try :
85
92
arr .append (None )
86
- print (" ERROR : expected an exception" )
93
+ print (" ERROR7 : expected an exception" )
87
94
except :
88
95
print (" caught an exception [ok]" )
89
96
90
97
try :
91
98
arr .extend ()
92
- print (" ERROR : expected an exception" )
99
+ print (" ERROR8 : expected an exception" )
93
100
except :
94
101
print (" caught an exception [ok]" )
95
102
try :
96
103
arr .extend (None )
97
- print (" ERROR : expected an exception" )
104
+ print (" ERROR9 : expected an exception" )
98
105
except :
99
106
print (" caught an exception [ok]" )
100
107
try :
101
108
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" )
103
121
except :
104
122
print (" caught an exception [ok]" )
105
123
pass
@@ -108,55 +126,48 @@ def assertEqual(x, y):
108
126
print ("## testing array.array(...)" )
109
127
try :
110
128
arr = array .array ()
111
- print ("ERROR : expected an exception" )
129
+ print ("ERROR1 : expected an exception" )
112
130
except :
113
131
print ("caught an exception [ok]" )
114
132
115
133
try :
116
134
arr = array .array (b"d" )
117
- print ("ERROR : expected an exception" )
135
+ print ("ERROR2 : expected an exception" )
118
136
except :
119
137
print ("caught an exception [ok]" )
120
138
121
139
try :
122
140
arr = array .array ("?" )
123
- print ("ERROR : expected an exception" )
141
+ print ("ERROR3 : expected an exception" )
124
142
except :
125
143
print ("caught an exception [ok]" )
126
144
127
145
try :
128
146
arr = array .array ("dd" )
129
- print ("ERROR : expected an exception" )
147
+ print ("ERROR4 : expected an exception" )
130
148
except :
131
149
print ("caught an exception [ok]" )
132
150
133
151
try :
134
152
arr = array .array ("d" , initializer = [1 ,2 ])
135
- print ("ERROR : expected an exception" )
153
+ print ("ERROR5 : expected an exception" )
136
154
except :
137
155
print ("caught an exception [ok]" )
138
156
139
157
try :
140
158
arr = array .array ("d" , [1 ], [])
141
- print ("ERROR : expected an exception" )
159
+ print ("ERROR6 : expected an exception" )
142
160
except :
143
161
print ("caught an exception [ok]" )
144
162
145
163
try :
146
164
arr = array .array ("d" , 1 )
147
- print ("ERROR : expected an exception" )
165
+ print ("ERROR7 : expected an exception" )
148
166
except :
149
167
print ("caught an exception [ok]" )
150
168
151
169
try :
152
170
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" )
161
172
except :
162
173
print ("caught an exception [ok]" )
0 commit comments