2017-06-27 23:12:06 +02:00
|
|
|
// Copyright 2015 Microsoft Corporation. All rights reserved.
|
|
|
|
// This code is governed by the license found in the LICENSE file.
|
|
|
|
|
|
|
|
/*---
|
|
|
|
description: >
|
|
|
|
Elements deleted after the call started and before visited are not
|
|
|
|
visited
|
|
|
|
esid: sec-array.from
|
|
|
|
---*/
|
|
|
|
|
2018-02-15 23:40:02 +01:00
|
|
|
var originalArray = [0, 1, -2, 4, -8, 16];
|
|
|
|
var array = [0, 1, -2, 4, -8, 16];
|
2017-06-27 23:12:06 +02:00
|
|
|
var a = [];
|
|
|
|
var arrayIndex = -1;
|
2018-02-15 23:40:02 +01:00
|
|
|
|
2017-06-27 23:12:06 +02:00
|
|
|
function mapFn(value, index) {
|
2018-02-15 23:40:02 +01:00
|
|
|
this.arrayIndex++;
|
2021-08-10 23:51:54 +02:00
|
|
|
assert.sameValue(value, array[this.arrayIndex], 'The value of value is expected to equal the value of array[this.arrayIndex]');
|
|
|
|
assert.sameValue(index, this.arrayIndex, 'The value of index is expected to equal the value of this.arrayIndex');
|
2017-06-27 23:12:06 +02:00
|
|
|
|
2018-02-15 23:40:02 +01:00
|
|
|
array.splice(array.length - 1, 1);
|
|
|
|
return 127;
|
2017-06-27 23:12:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
a = Array.from(array, mapFn, this);
|
|
|
|
|
2021-08-10 23:51:54 +02:00
|
|
|
assert.sameValue(a.length, originalArray.length / 2, 'The value of a.length is expected to be originalArray.length / 2');
|
2017-06-27 23:12:06 +02:00
|
|
|
|
|
|
|
for (var j = 0; j < originalArray.length / 2; j++) {
|
2021-08-10 23:51:54 +02:00
|
|
|
assert.sameValue(a[j], 127, 'The value of a[j] is expected to be 127');
|
2017-06-27 23:12:06 +02:00
|
|
|
}
|