Debian Codegraph @

js/src/tests/test262/built-ins/Array/from/elements-deleted-after.js

raw
1 // Copyright 2015 Microsoft Corporation. All rights reserved.
2 // This code is governed by the license found in the LICENSE file.
3
4 /*---
5 description: >
6 Elements deleted after the call started and before visited are not
7 visited
8 esid: sec-array.from
9 ---*/
10
11 var originalArray = [0, 1, -2, 4, -8, 16];
12 var array = [0, 1, -2, 4, -8, 16];
13 var a = [];
14 var arrayIndex = -1;
15
16 function mapFn(value, index) {
17 this.arrayIndex++;
18 assert.sameValue(value, array[this.arrayIndex], 'The value of value is expected to equal the value of array[this.arrayIndex]');
19 assert.sameValue(index, this.arrayIndex, 'The value of index is expected to equal the value of this.arrayIndex');
20
21 array.splice(array.length - 1, 1);
22 return 127;
23 }
24
25
26 a = Array.from(array, mapFn, this);
27
28 assert.sameValue(a.length, originalArray.length / 2, 'The value of a.length is expected to be originalArray.length / 2');
29
30 for (var j = 0; j < originalArray.length / 2; j++) {
31 assert.sameValue(a[j], 127, 'The value of a[j] is expected to be 127');
32 }
33
34 reportCompare(0, 0);