source-array-boundary.js (1448B)
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], 'The value of value is expected to equal the value of array[this.arrayIndex]'); 16 assert.sameValue(index, this.arrayIndex, 'The value of index is expected to equal the value of this.arrayIndex'); 17 18 return value; 19 } 20 21 var a = Array.from(array, mapFn, this); 22 23 assert.sameValue(a.length, array.length, 'The value of a.length is expected to equal the value of array.length'); 24 assert.sameValue(a[0], Number.MAX_VALUE, 'The value of a[0] is expected to equal the value of Number.MAX_VALUE'); 25 assert.sameValue(a[1], Number.MIN_VALUE, 'The value of a[1] is expected to equal the value of Number.MIN_VALUE'); 26 assert.sameValue(a[2], Number.NaN, 'The value of a[2] is expected to equal the value of Number.NaN'); 27 assert.sameValue(a[3], Number.NEGATIVE_INFINITY, 'The value of a[3] is expected to equal the value of Number.NEGATIVE_INFINITY'); 28 assert.sameValue(a[4], Number.POSITIVE_INFINITY, 'The value of a[4] is expected to equal the value of Number.POSITIVE_INFINITY'); 29 30 reportCompare(0, 0);