@@ -8,7 +8,7 @@ if $*KERNEL.bits == 64 {
8
8
@ uint . push : uint64 ;
9
9
}
10
10
11
- plan (@ int + @ uint ) * 136 + @ uint * 2 ;
11
+ plan (@ int + @ uint ) * 157 + @ uint * 2 ;
12
12
13
13
# Basic native int array tests.
14
14
for flat @ int ,@ uint -> $ T {
@@ -140,41 +140,75 @@ for flat @int,@uint -> $T {
140
140
" Cannot push non-int/Int to $ t array" ;
141
141
throws-like { @ arr [0 ] := my $ a }, Exception ,
142
142
message => ' Cannot bind to a natively typed array' ,
143
- " Cannot push non-int/Int to $ t array" ;
143
+ " Cannot bind to $ t array" ;
144
144
throws-like { @ arr [0 ]: delete }, Exception ,
145
145
message => ' Cannot delete from a natively typed array' ,
146
- " Cannot push non-int/Int to $ t array" ;
146
+ " Cannot delete from $ t array" ;
147
147
148
- is (@ arr . push (101 , 105 )), (42 ,101 ,105 ), " can push multiple to $ t array" ;
148
+ is (@ arr . push (101 , 105 )), (42 ,101 ,105 ),
149
+ " can push multiple to $ t array" ;
149
150
is @ arr . elems , 3 , " push multiple to $ t array works (1)" ;
150
151
is @ arr [1 ], 101 , " push multiple to $ t array works (2)" ;
151
152
is @ arr [2 ], 105 , " push multiple to $ t array works (3)" ;
152
153
throws-like { @ arr . push (' omg' , ' wtf' ) }, Exception ,
153
154
" Cannot push non-int/Int to $ t array (multiple push)" ;
154
155
155
- is @ arr . pop , 105 , " pop from $ t array works (1)" ;
156
- is @ arr . elems , 2 , " pop from $ t array works (2)" ;
157
-
158
- is (@ arr . unshift (1 )), (1 ,42 ,101 ), " can unshift to $ t array" ;
159
- is @ arr . elems , 3 , " unshift to $ t array works (1)" ;
156
+ is @ arr . append (66 ), (42 ,101 ,105 ,66 ), " can append to $ t array" ;
157
+ is @ arr . elems , 4 , " append to $ t array works (1)" ;
158
+ is @ arr [3 ], 66 , " append to $ t array works (2)" ;
159
+ throws-like { @ arr . append (' it real good' ) }, Exception ,
160
+ " Cannot append non-int/Int to $ t array" ;
161
+
162
+ is (@ arr . append (21 ,25 )), (42 ,101 ,105 ,66 ,21 ,25 ),
163
+ " can append multiple to $ t array" ;
164
+ is @ arr . elems , 6 , " append multiple to $ t array works (1)" ;
165
+ is @ arr [4 ], 21 , " append multiple to $ t array works (2)" ;
166
+ is @ arr [5 ], 25 , " append multiple to $ t array works (3)" ;
167
+ throws-like { @ arr . append (' omg' , ' wtf' ) }, Exception ,
168
+ " Cannot append non-int/Int to $ t array (multiple append)" ;
169
+
170
+ is @ arr . pop , 25 , " pop from $ t array works (1)" ;
171
+ is @ arr . elems , 5 , " pop from $ t array works (2)" ;
172
+
173
+ is (@ arr . unshift (1 )), (1 ,42 ,101 ,105 ,66 ,21 ),
174
+ " can unshift to $ t array" ;
175
+ is @ arr . elems , 6 , " unshift to $ t array works (1)" ;
160
176
is @ arr [0 ], 1 , " unshift to $ t array works (2)" ;
161
177
is @ arr [1 ], 42 , " unshift to $ t array works (3)" ;
162
178
# RT #125123
163
- throws-like { @ arr . unshift (' part of the day not working' ) }, X::TypeCheck ,
164
- got => Str ,
179
+ throws-like { @ arr . unshift (' part of the day not working' ) }, Exception ,
165
180
" Cannot unshift non-int/Int to $ t array" ;
166
181
167
- is (@ arr . unshift (3 ,2 )), (3 ,2 ,1 ,42 ,101 )," can unshift multiple to $ t array" ;
168
- is @ arr . elems , 5 , " unshift multiple to $ t array works (1)" ;
182
+ is (@ arr . unshift (3 ,2 )), (3 ,2 ,1 ,42 ,101 ,105 ,66 ,21 ),
183
+ " can unshift multiple to $ t array" ;
184
+ is @ arr . elems , 8 , " unshift multiple to $ t array works (1)" ;
169
185
is @ arr [0 ], 3 , " unshift multiple to $ t array works (2)" ;
170
186
is @ arr [1 ], 2 , " unshift multiple to $ t array works (3)" ;
171
187
is @ arr [2 ], 1 , " unshift multiple to $ t array works (4)" ;
172
188
is @ arr [3 ], 42 , " unshift multiple to $ t array works (5)" ;
173
189
throws-like { @ arr . unshift (' wtf' , ' bbq' ) }, Exception ,
174
190
" Cannot unshift non-int/Int to $ t array (multiple unshift)" ;
175
191
176
- is @ arr . shift , 3 , " shift from $ t array works (1)" ;
177
- is @ arr . elems , 4 , " shift from $ t array works (2)" ;
192
+ is (@ arr . prepend (4 )), (4 ,3 ,2 ,1 ,42 ,101 ,105 ,66 ,21 ),
193
+ " can prepend to $ t array" ;
194
+ is @ arr . elems , 9 , " prepend to $ t array works (1)" ;
195
+ is @ arr [0 ], 4 , " prepend to $ t array works (2)" ;
196
+ is @ arr [1 ], 3 , " prepend to $ t array works (3)" ;
197
+ throws-like { @ arr . prepend (' part of the day not working' ) }, Exception ,
198
+ " Cannot prepend non-int/Int to $ t array" ;
199
+
200
+ is (@ arr . prepend (6 ,5 )), (6 ,5 ,4 ,3 ,2 ,1 ,42 ,101 ,105 ,66 ,21 ),
201
+ " can prepend multiple to $ t array" ;
202
+ is @ arr . elems , 11 , " unshift multiple to $ t array works (1)" ;
203
+ is @ arr [0 ], 6 , " prepend multiple to $ t array works (2)" ;
204
+ is @ arr [1 ], 5 , " prepend multiple to $ t array works (3)" ;
205
+ is @ arr [2 ], 4 , " prepend multiple to $ t array works (4)" ;
206
+ is @ arr [3 ], 3 , " prepend multiple to $ t array works (5)" ;
207
+ throws-like { @ arr . prepend (' wtf' , ' bbq' ) }, Exception ,
208
+ " Cannot prepend non-int/Int to $ t array (multiple unshift)" ;
209
+
210
+ is @ arr . shift , 6 , " shift from $ t array works (1)" ;
211
+ is @ arr . elems , 10 , " shift from $ t array works (2)" ;
178
212
179
213
is (@ arr = 1 .. 10 ), (1 .. 10 ). List , " can initialize $ t from Range" ;
180
214
my @ replaced = @ arr . splice (3 , 2 , 98 , 99 , 100 );
0 commit comments