2 "Test of array with toString() override that truncates array."
8 var countToDelete
= maxSize
- keepSize
;
10 var a
= new Array(maxSize
);
13 if (window
.GCController
)
14 return GCController
.collect();
16 for (var i
= 0; i
< 1000; i
++)
24 function toString_Mutate() {
25 a
.splice(keepSize
, countToDelete
);
27 for (var i
= keepSize
; i
< countToDelete
; i
++) {
31 if ((this != undefined) && (this.value
!= undefined)) {
32 var s
= this.value
.toString();
33 if (s
.length
< digits
)
34 s
= ('0000' + s
).slice(-digits
);
42 for (var i
= 0; i
< a
.length
; i
++) {
43 a
[i
] = new Item(a
.length
- i
- 1);
44 a
[i
].toString
= toString_Mutate
;
48 if (a
.length
== maxSize
)
49 testPassed("Array length is unchanged.");
51 testFailed("Array length should be " + maxSize
+ " but is " + a
.length
+ ".");
53 var firstFailedValue
= -1;
55 for (var i
= 0; i
< a
.length
; i
++) {
56 if (a
[i
].value
!= i
) {
62 if (firstFailedValue
== -1)
63 testPassed("Array values are correct.");
65 testFailed("Array values are wrong, first bad value at index " + firstFailedValue
+ ", should be " + firstFailedValue
+ " was " + a
[firstFailedValue
].value
+ ".");
67 testFailed("Got exception processing sort()");
70 for (var i
= 0; i
< a
.length
; i
++) {