@@ -175,3 +175,200 @@ try {
175
175
assert ( e . message === "foo" ) ;
176
176
assert ( e instanceof ReferenceError ) ;
177
177
}
178
+
179
+ try {
180
+ Array . prototype . splice . call ( undefined ) ;
181
+ assert ( false ) ;
182
+ } catch ( e ) {
183
+ assert ( e instanceof TypeError ) ;
184
+ }
185
+
186
+ try {
187
+ var o = { } ;
188
+ Object . defineProperty ( o , 'toString' , { 'get' : function ( ) { throw new ReferenceError ( "foo" ) ; } } ) ;
189
+ var a = { length : o } ;
190
+ Array . prototype . splice . call ( a , function ( ) { } ) ;
191
+ assert ( false ) ;
192
+ } catch ( e ) {
193
+ assert ( e instanceof ReferenceError ) ;
194
+ assert ( e . message == "foo" ) ;
195
+ }
196
+
197
+ try {
198
+ var o = { } ;
199
+ Object . defineProperty ( o , 'toString' , { 'get' : function ( ) { throw new ReferenceError ( "1" ) ; } } ) ;
200
+ [ 1 , 2 ] . splice ( o ) ;
201
+ assert ( false ) ;
202
+ } catch ( e ) {
203
+ assert ( e instanceof ReferenceError ) ;
204
+ assert ( e . message == "1" ) ;
205
+ }
206
+
207
+ try {
208
+ var o = { } ;
209
+ Object . defineProperty ( o , 'toString' , { 'get' : function ( ) { throw new ReferenceError ( "2" ) ; } } ) ;
210
+ [ 1 , 2 ] . splice ( 1 , o ) ;
211
+ assert ( false ) ;
212
+ } catch ( e ) {
213
+ assert ( e instanceof ReferenceError ) ;
214
+ assert ( e . message == "2" ) ;
215
+ }
216
+
217
+ try {
218
+ var a = [ 1 , 5 , , 2 ] ;
219
+ Object . defineProperty ( a , '2' , { 'get' : function ( ) { throw new ReferenceError ( "3" ) ; } } ) ;
220
+ a . splice ( 1 , 7 , 7 , 7 , 7 , 7 ) ;
221
+ assert ( false ) ;
222
+ } catch ( e ) {
223
+ assert ( e instanceof ReferenceError ) ;
224
+ assert ( e . message == "3" ) ;
225
+ }
226
+
227
+ var a = { length : 13 } ;
228
+ Array . prototype . splice . call ( a , function ( ) { delete a } ) ;
229
+ assert ( a . length === 0 ) ;
230
+
231
+ try {
232
+ var a = [ 1 , 5 , 6 , 7 , 8 , 5 ] ;
233
+ Object . defineProperty ( a , '0' , { 'get' : function ( ) { throw new ReferenceError ( "foo0" ) ; } } ) ;
234
+ Array . prototype . splice . call ( a , 0 , 3 ) ;
235
+ assert ( false ) ;
236
+ } catch ( e ) {
237
+ assert ( e instanceof ReferenceError ) ;
238
+ assert ( e . message == "foo0" ) ;
239
+ }
240
+
241
+ try {
242
+ f = function ( ) { delete arr [ 3 ] ; arr . length = 13 ; Object . defineProperty ( arr , '5' , function ( ) { } ) } ;
243
+ obj = { get : f , valueOf : f , toString : f } ;
244
+ arr = [ 1 , 2 , obj , 4 , 5 ] ;
245
+ Object . defineProperty ( arr , '2' , { 'get' : f } ) ;
246
+ print ( arr ) ;
247
+ arr . splice ( 1 , 4 , obj ) ;
248
+ } catch ( e ) { }
249
+
250
+ try {
251
+ f = function ( ) { for ( var i = 0 ; i < arr . length ; i ++ ) { delete arr [ i ] } } ;
252
+ obj = { get : f , valueOf : f , toString : f } ;
253
+ arr = [ 1 , 2 , obj , 4 , 5 ] ;
254
+ Object . defineProperty ( arr , '0' , { 'get' : f } ) ;
255
+ Object . defineProperty ( arr , '1' , { 'get' : f } ) ;
256
+ Object . defineProperty ( arr , '2' , { 'get' : f } ) ;
257
+ Object . defineProperty ( arr , '3' , { 'get' : f } ) ;
258
+ Object . defineProperty ( arr , '4' , { 'get' : f } ) ;
259
+ Object . defineProperty ( arr , '5' , { 'get' : f } ) ;
260
+ arr . splice ( 1 , 3 , obj ) ;
261
+ assert ( false ) ;
262
+ } catch ( e ) {
263
+ assert ( e instanceof TypeError ) ;
264
+ }
265
+
266
+ try {
267
+ f = function ( ) { throw new TypeError ( "4" ) ; } ;
268
+ obj = { get : f , valueOf : f , toString : f } ;
269
+ arr = [ 1 , 2 , obj , 4 , 5 ] ;
270
+ Object . defineProperty ( arr , '4' , { 'get' : f } ) ;
271
+ arr . splice ( 1 , 3 , obj ) ;
272
+ assert ( false ) ;
273
+ } catch ( e ) {
274
+ assert ( e instanceof TypeError ) ;
275
+ assert ( e . message == "4" ) ;
276
+ }
277
+
278
+ try {
279
+ f = function ( ) { for ( var i = 0 ; i < arr . length ; i ++ ) { delete arr [ i ] } } ;
280
+ f1 = function ( ) { delete arr [ 2 ] ; } ;
281
+ f2 = function ( ) { delete arr [ 3 ] ; } ;
282
+ f3 = function ( ) { delete arr [ 4 ] ; } ;
283
+ arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 ] ;
284
+ delete arr [ 2 ] ;
285
+ delete arr [ 3 ] ;
286
+ Object . defineProperty ( arr , '0' , { 'get' : f } ) ;
287
+ Object . defineProperty ( arr , '1' , { 'get' : f } ) ;
288
+ Object . defineProperty ( arr , '2' , { 'get' : f } ) ;
289
+ Object . defineProperty ( arr , '3' , { 'get' : f } ) ;
290
+ Object . defineProperty ( arr , '8' , { 'get' : f1 } ) ;
291
+ Object . defineProperty ( arr , '9' , { 'get' : f2 } ) ;
292
+ Object . defineProperty ( arr , '10' , { 'get' : f3 } ) ;
293
+ arr . splice ( 1 , 7 , 5 ) ;
294
+ } catch ( e ) {
295
+ assert ( e instanceof TypeError ) ;
296
+ }
297
+
298
+ try {
299
+ f = function ( ) { for ( var i = 0 ; i < arr . length ; i ++ ) { delete arr [ i ] } } ;
300
+ f1 = function ( ) { delete arr [ 2 ] ; } ;
301
+ f2 = function ( ) { delete arr [ 3 ] ; } ;
302
+ f3 = function ( ) { delete arr [ 4 ] ; } ;
303
+ arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 ] ;
304
+ delete arr [ 2 ] ;
305
+ delete arr [ 3 ] ;
306
+ Object . defineProperty ( arr , '0' , { 'get' : f } ) ;
307
+ Object . defineProperty ( arr , '1' , { 'get' : f } ) ;
308
+ Object . defineProperty ( arr , '2' , { 'get' : f } ) ;
309
+ Object . defineProperty ( arr , '3' , { 'get' : f } ) ;
310
+ Object . defineProperty ( arr , '8' , { 'get' : f } ) ;
311
+ Object . defineProperty ( arr , '9' , { 'get' : f2 } ) ;
312
+ Object . defineProperty ( arr , '10' , { 'get' : f3 } ) ;
313
+ arr . splice ( 1 , 7 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 ) ;
314
+ assert ( false ) ;
315
+ } catch ( e ) {
316
+ assert ( e instanceof TypeError ) ;
317
+ }
318
+
319
+ try {
320
+ var a = [ 1 , 5 , 6 , 7 , 8 , 5 ] ;
321
+ Object . defineProperty ( a , '1' , { 'get' : function ( ) { throw new ReferenceError ( "foo1" ) ; } } ) ;
322
+ Object . defineProperty ( a , '0' , { 'get' : function ( ) { throw new ReferenceError ( "foo0" ) ; } } ) ;
323
+ Object . defineProperty ( a , '2' , { 'get' : function ( ) { throw new ReferenceError ( "foo2" ) ; } } ) ;
324
+ Array . prototype . splice . call ( a , 0 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 ) ;
325
+ assert ( false ) ;
326
+ } catch ( e ) {
327
+ assert ( e instanceof ReferenceError ) ;
328
+ assert ( e . message == "foo0" ) ;
329
+ }
330
+
331
+ try {
332
+ f = function ( ) { for ( var i = 0 ; i < arr . length ; i ++ ) { delete arr [ i ] } } ;
333
+ arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 ] ;
334
+ delete arr [ 22 ] ;
335
+ delete arr [ 23 ] ;
336
+ Object . defineProperty ( arr , '21' , { 'get' : f } ) ;
337
+ Object . defineProperty ( arr , '22' , { 'get' : f } ) ;
338
+ Object . defineProperty ( arr , '23' , { 'get' : f } ) ;
339
+ arr . splice ( 1 , 7 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 ) ;
340
+ assert ( false ) ;
341
+ } catch ( e ) {
342
+ assert ( e instanceof TypeError ) ;
343
+ }
344
+
345
+ try {
346
+ f = function ( ) { throw new TypeError ( "6" ) ; } ;
347
+ arr = [ 1 , 2 , 4 , 5 ] ;
348
+ Object . defineProperty ( arr , '4' , { 'get' : f } ) ;
349
+ arr . splice ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ) ;
350
+ assert ( false ) ;
351
+ } catch ( e ) {
352
+ assert ( e instanceof TypeError ) ;
353
+ assert ( e . message == "6" ) ;
354
+ }
355
+
356
+ try {
357
+ f = function ( ) { delete arr [ 23 ] ; } ;
358
+ arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 ] ;
359
+ delete arr [ 23 ] ;
360
+ Object . defineProperty ( arr , '23' , { 'get' : f } ) ;
361
+ arr . splice ( 1 , 7 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 , 5 ) ;
362
+ assert ( false ) ;
363
+ } catch ( e ) {
364
+ assert ( e instanceof TypeError ) ;
365
+ }
366
+
367
+ try {
368
+ arr = [ ] ;
369
+ Object . defineProperty ( arr , 'length' , { value : 999 , writable : false } ) ;
370
+ arr . splice ( 1 , 2 , 4 , 5 ) ;
371
+ assert ( false ) ;
372
+ } catch ( e ) {
373
+ assert ( e instanceof TypeError ) ;
374
+ }
0 commit comments