Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Array/from/elements-updated-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: Elements are updated after the call to from
6 esid: sec-array.from
7 es6id: 22.1.2.1
8 ---*/
9
10 var array = [127, 4, 8, 16, 32, 64, 128];
11 var arrayIndex = -1;
12
13 function mapFn(value, index) {
14 arrayIndex++;
15 if (index + 1 < array.length) {
16 array[index + 1] = 127;
17 }
18 assert.sameValue(value, 127, "Value mismatch in mapFn at index " + index + ".");
19 assert.sameValue(index, arrayIndex, "Index mismatch in mapFn.");
20
21 return value;
22 }
23
24 var a = Array.from(array, mapFn);
25 assert.sameValue(a.length, array.length, "Length mismatch.");
26 for (var j = 0; j < a.length; j++) {
27 assert.sameValue(a[j], 127, "Element mismatch for mapped array.");
28 }