elements-updated-after.js (883B)
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 ---*/ 8 9 var array = [127, 4, 8, 16, 32, 64, 128]; 10 var arrayIndex = -1; 11 12 function mapFn(value, index) { 13 arrayIndex++; 14 if (index + 1 < array.length) { 15 array[index + 1] = 127; 16 } 17 assert.sameValue(value, 127, 'The value of value is expected to be 127'); 18 assert.sameValue(index, arrayIndex, 'The value of index is expected to equal the value of arrayIndex'); 19 20 return value; 21 } 22 23 var a = Array.from(array, mapFn); 24 assert.sameValue(a.length, array.length, 'The value of a.length is expected to equal the value of array.length'); 25 for (var j = 0; j < a.length; j++) { 26 assert.sameValue(a[j], 127, 'The value of a[j] is expected to be 127'); 27 } 28 29 reportCompare(0, 0);