| 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: Source array with boundary values |
| 6 |
esid: sec-array.from |
| 7 |
es6id: 22.1.2.1 |
| 8 |
---*/ |
| 9 |
|
| 10 |
var array = [Number.MAX_VALUE, Number.MIN_VALUE, Number.NaN, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY]; |
| 11 |
var arrayIndex = -1; |
| 12 |
|
| 13 |
function mapFn(value, index) { |
| 14 |
this.arrayIndex++; |
| 15 |
assert.sameValue(value, array[this.arrayIndex], "Value mismatch in mapFn at index " + index + "."); |
| 16 |
assert.sameValue(index, this.arrayIndex, "Index mismatch in mapFn."); |
| 17 |
|
| 18 |
return value; |
| 19 |
} |
| 20 |
|
| 21 |
var a = Array.from(array, mapFn, this); |
| 22 |
|
| 23 |
assert.sameValue(a.length, array.length, "Length mismatch."); |
| 24 |
assert.sameValue(a[0], Number.MAX_VALUE, "Element mismatch for mapped array at index 0."); |
| 25 |
assert.sameValue(a[1], Number.MIN_VALUE, "Element mismatch for mapped array at index 1."); |
| 26 |
assert.sameValue(a[2], Number.NaN, "Element mismatch for mapped array at index 2."); |
| 27 |
assert.sameValue(a[3], Number.NEGATIVE_INFINITY, "Element mismatch for mapped array at index 3."); |
| 28 |
assert.sameValue(a[4], Number.POSITIVE_INFINITY, "Element mismatch for mapped array at index 4."); |