diff --git a/test/built-ins/Array/from/Array.from-descriptor.js b/test/built-ins/Array/from/Array.from-descriptor.js index 7fcb331e09fcfe4980995780824ff870c980c2f4..38778287b65f424edf5d137b84252076f03048ba 100644 --- a/test/built-ins/Array/from/Array.from-descriptor.js +++ b/test/built-ins/Array/from/Array.from-descriptor.js @@ -5,6 +5,7 @@ description: Testing descriptor property of Array.from includes: - propertyHelper.js +esid: sec-array.from es6id: 22.1.2.1 ---*/ diff --git a/test/built-ins/Array/from/Array.from-name.js b/test/built-ins/Array/from/Array.from-name.js index cb05ac2b5d411a18114a1423c0425d5e6ba79cfa..add03df6c549c0e1ba6f4fb2486d7f055cea5247 100644 --- a/test/built-ins/Array/from/Array.from-name.js +++ b/test/built-ins/Array/from/Array.from-name.js @@ -1,6 +1,7 @@ // Copyright 2015 Microsoft Corporation. All rights reserved. // This code is governed by the license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: '`name` property' info: > diff --git a/test/built-ins/Array/from/Array.from_arity.js b/test/built-ins/Array/from/Array.from_arity.js index 85f53379ce18ef466acb9709de433d60c9e82638..ad5e8a6aae0aa901947315ec357e75fda80b13f7 100644 --- a/test/built-ins/Array/from/Array.from_arity.js +++ b/test/built-ins/Array/from/Array.from_arity.js @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: > The length property of the Array.from method is 1. diff --git a/test/built-ins/Array/from/Array.from_forwards-length-for-array-likes.js b/test/built-ins/Array/from/Array.from_forwards-length-for-array-likes.js index 8c946efd40e221c566e1d47bc6f0bed59fe0006f..5b3491a4bf6d39c9dd7e09ee460775a88cd8cb87 100644 --- a/test/built-ins/Array/from/Array.from_forwards-length-for-array-likes.js +++ b/test/built-ins/Array/from/Array.from_forwards-length-for-array-likes.js @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: > If this is a constructor, and items doesn't have an @@iterator, diff --git a/test/built-ins/Array/from/calling-from-valid-1-noStrict.js b/test/built-ins/Array/from/calling-from-valid-1-noStrict.js index c2b351e2ff4e476dde630c960f944d361081e862..81f419cbb9e3f7dd2c8fdde60d92fb5370bb978e 100644 --- a/test/built-ins/Array/from/calling-from-valid-1-noStrict.js +++ b/test/built-ins/Array/from/calling-from-valid-1-noStrict.js @@ -1,66 +1,67 @@ -// Copyright 2015 Microsoft Corporation. All rights reserved. -// This code is governed by the license found in the LICENSE file. -/*--- -es6id: 22.1.2.1 -description: Map function without thisArg on non strict mode -info: > - 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) - - ... - 10. Let len be ToLength(Get(arrayLike, "length")). - 11. ReturnIfAbrupt(len). - 12. If IsConstructor(C) is true, then - a. Let A be Construct(C, «len»). - 13. Else, - b. Let A be ArrayCreate(len). - 14. ReturnIfAbrupt(A). - 15. Let k be 0. - 16. Repeat, while k < len - a. Let Pk be ToString(k). - b. Let kValue be Get(arrayLike, Pk). - c. ReturnIfAbrupt(kValue). - d. If mapping is true, then - i. Let mappedValue be Call(mapfn, T, «kValue, k»). - ... -flags: [noStrict] ----*/ - -var list = { - '0': 41, - '1': 42, - '2': 43, - length: 3 -}; -var calls = []; - -function mapFn (value) { - calls.push({ - args: arguments, - thisArg: this - }); - return value * 2; -} - -var result = Array.from(list, mapFn); - -assert.sameValue(result.length, 3, 'result.length'); -assert.sameValue(result[0], 82, 'result[0]'); -assert.sameValue(result[1], 84, 'result[1]'); -assert.sameValue(result[2], 86, 'result[2]'); - -assert.sameValue(calls.length, 3, 'calls.length'); - -assert.sameValue(calls[0].args.length, 2, 'calls[0].args.length'); -assert.sameValue(calls[0].args[0], 41, 'calls[0].args[0]'); -assert.sameValue(calls[0].args[1], 0, 'calls[0].args[1]'); -assert.sameValue(calls[0].thisArg, this, 'calls[0].thisArg'); - -assert.sameValue(calls[1].args.length, 2, 'calls[1].args.length'); -assert.sameValue(calls[1].args[0], 42, 'calls[1].args[0]'); -assert.sameValue(calls[1].args[1], 1, 'calls[1].args[1]'); -assert.sameValue(calls[1].thisArg, this, 'calls[1].thisArg'); - -assert.sameValue(calls[2].args.length, 2, 'calls[2].args.length'); -assert.sameValue(calls[2].args[0], 43, 'calls[2].args[0]'); -assert.sameValue(calls[2].args[1], 2, 'calls[2].args[1]'); -assert.sameValue(calls[2].thisArg, this, 'calls[2].thisArg'); \ No newline at end of file +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. +/*--- +esid: sec-array.from +es6id: 22.1.2.1 +description: Map function without thisArg on non strict mode +info: > + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + + ... + 10. Let len be ToLength(Get(arrayLike, "length")). + 11. ReturnIfAbrupt(len). + 12. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + 13. Else, + b. Let A be ArrayCreate(len). + 14. ReturnIfAbrupt(A). + 15. Let k be 0. + 16. Repeat, while k < len + a. Let Pk be ToString(k). + b. Let kValue be Get(arrayLike, Pk). + c. ReturnIfAbrupt(kValue). + d. If mapping is true, then + i. Let mappedValue be Call(mapfn, T, «kValue, k»). + ... +flags: [noStrict] +---*/ + +var list = { + '0': 41, + '1': 42, + '2': 43, + length: 3 +}; +var calls = []; + +function mapFn (value) { + calls.push({ + args: arguments, + thisArg: this + }); + return value * 2; +} + +var result = Array.from(list, mapFn); + +assert.sameValue(result.length, 3, 'result.length'); +assert.sameValue(result[0], 82, 'result[0]'); +assert.sameValue(result[1], 84, 'result[1]'); +assert.sameValue(result[2], 86, 'result[2]'); + +assert.sameValue(calls.length, 3, 'calls.length'); + +assert.sameValue(calls[0].args.length, 2, 'calls[0].args.length'); +assert.sameValue(calls[0].args[0], 41, 'calls[0].args[0]'); +assert.sameValue(calls[0].args[1], 0, 'calls[0].args[1]'); +assert.sameValue(calls[0].thisArg, this, 'calls[0].thisArg'); + +assert.sameValue(calls[1].args.length, 2, 'calls[1].args.length'); +assert.sameValue(calls[1].args[0], 42, 'calls[1].args[0]'); +assert.sameValue(calls[1].args[1], 1, 'calls[1].args[1]'); +assert.sameValue(calls[1].thisArg, this, 'calls[1].thisArg'); + +assert.sameValue(calls[2].args.length, 2, 'calls[2].args.length'); +assert.sameValue(calls[2].args[0], 43, 'calls[2].args[0]'); +assert.sameValue(calls[2].args[1], 2, 'calls[2].args[1]'); +assert.sameValue(calls[2].thisArg, this, 'calls[2].thisArg'); diff --git a/test/built-ins/Array/from/calling-from-valid-1-onlyStrict.js b/test/built-ins/Array/from/calling-from-valid-1-onlyStrict.js index 7b2e603b2c872e2f2615dbfbd4afcbfb85ff8689..e794e6ea4a33773cfe6df7f215d1494749b6dc95 100644 --- a/test/built-ins/Array/from/calling-from-valid-1-onlyStrict.js +++ b/test/built-ins/Array/from/calling-from-valid-1-onlyStrict.js @@ -1,66 +1,67 @@ -// Copyright 2015 Microsoft Corporation. All rights reserved. -// This code is governed by the license found in the LICENSE file. -/*--- -es6id: 22.1.2.1 -description: Map function without thisArg on strict mode -info: > - 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) - - ... - 10. Let len be ToLength(Get(arrayLike, "length")). - 11. ReturnIfAbrupt(len). - 12. If IsConstructor(C) is true, then - a. Let A be Construct(C, «len»). - 13. Else, - b. Let A be ArrayCreate(len). - 14. ReturnIfAbrupt(A). - 15. Let k be 0. - 16. Repeat, while k < len - a. Let Pk be ToString(k). - b. Let kValue be Get(arrayLike, Pk). - c. ReturnIfAbrupt(kValue). - d. If mapping is true, then - i. Let mappedValue be Call(mapfn, T, «kValue, k»). - ... -flags: [onlyStrict] ----*/ - -var list = { - '0': 41, - '1': 42, - '2': 43, - length: 3 -}; -var calls = []; - -function mapFn (value) { - calls.push({ - args: arguments, - thisArg: this - }); - return value * 2; -} - -var result = Array.from(list, mapFn); - -assert.sameValue(result.length, 3, 'result.length'); -assert.sameValue(result[0], 82, 'result[0]'); -assert.sameValue(result[1], 84, 'result[1]'); -assert.sameValue(result[2], 86, 'result[2]'); - -assert.sameValue(calls.length, 3, 'calls.length'); - -assert.sameValue(calls[0].args.length, 2, 'calls[0].args.length'); -assert.sameValue(calls[0].args[0], 41, 'calls[0].args[0]'); -assert.sameValue(calls[0].args[1], 0, 'calls[0].args[1]'); -assert.sameValue(calls[0].thisArg, undefined, 'calls[0].thisArg'); - -assert.sameValue(calls[1].args.length, 2, 'calls[1].args.length'); -assert.sameValue(calls[1].args[0], 42, 'calls[1].args[0]'); -assert.sameValue(calls[1].args[1], 1, 'calls[1].args[1]'); -assert.sameValue(calls[1].thisArg, undefined, 'calls[1].thisArg'); - -assert.sameValue(calls[2].args.length, 2, 'calls[2].args.length'); -assert.sameValue(calls[2].args[0], 43, 'calls[2].args[0]'); -assert.sameValue(calls[2].args[1], 2, 'calls[2].args[1]'); -assert.sameValue(calls[2].thisArg, undefined, 'calls[2].thisArg'); \ No newline at end of file +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. +/*--- +esid: sec-array.from +es6id: 22.1.2.1 +description: Map function without thisArg on strict mode +info: > + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + + ... + 10. Let len be ToLength(Get(arrayLike, "length")). + 11. ReturnIfAbrupt(len). + 12. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + 13. Else, + b. Let A be ArrayCreate(len). + 14. ReturnIfAbrupt(A). + 15. Let k be 0. + 16. Repeat, while k < len + a. Let Pk be ToString(k). + b. Let kValue be Get(arrayLike, Pk). + c. ReturnIfAbrupt(kValue). + d. If mapping is true, then + i. Let mappedValue be Call(mapfn, T, «kValue, k»). + ... +flags: [onlyStrict] +---*/ + +var list = { + '0': 41, + '1': 42, + '2': 43, + length: 3 +}; +var calls = []; + +function mapFn (value) { + calls.push({ + args: arguments, + thisArg: this + }); + return value * 2; +} + +var result = Array.from(list, mapFn); + +assert.sameValue(result.length, 3, 'result.length'); +assert.sameValue(result[0], 82, 'result[0]'); +assert.sameValue(result[1], 84, 'result[1]'); +assert.sameValue(result[2], 86, 'result[2]'); + +assert.sameValue(calls.length, 3, 'calls.length'); + +assert.sameValue(calls[0].args.length, 2, 'calls[0].args.length'); +assert.sameValue(calls[0].args[0], 41, 'calls[0].args[0]'); +assert.sameValue(calls[0].args[1], 0, 'calls[0].args[1]'); +assert.sameValue(calls[0].thisArg, undefined, 'calls[0].thisArg'); + +assert.sameValue(calls[1].args.length, 2, 'calls[1].args.length'); +assert.sameValue(calls[1].args[0], 42, 'calls[1].args[0]'); +assert.sameValue(calls[1].args[1], 1, 'calls[1].args[1]'); +assert.sameValue(calls[1].thisArg, undefined, 'calls[1].thisArg'); + +assert.sameValue(calls[2].args.length, 2, 'calls[2].args.length'); +assert.sameValue(calls[2].args[0], 43, 'calls[2].args[0]'); +assert.sameValue(calls[2].args[1], 2, 'calls[2].args[1]'); +assert.sameValue(calls[2].thisArg, undefined, 'calls[2].thisArg'); diff --git a/test/built-ins/Array/from/calling-from-valid-2.js b/test/built-ins/Array/from/calling-from-valid-2.js index 7ae61c8ebf5c99518f9155aef0ee1f25a8d88c11..9831ec5e4762096419f4018d03f433c3aa20d096 100644 --- a/test/built-ins/Array/from/calling-from-valid-2.js +++ b/test/built-ins/Array/from/calling-from-valid-2.js @@ -1,67 +1,68 @@ -// Copyright 2015 Microsoft Corporation. All rights reserved. -// This code is governed by the license found in the LICENSE file. - -/*--- -es6id: 22.1.2.1 -description: Calling from with a valid map function with thisArg -info: > - 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) - - ... - 10. Let len be ToLength(Get(arrayLike, "length")). - 11. ReturnIfAbrupt(len). - 12. If IsConstructor(C) is true, then - a. Let A be Construct(C, «len»). - 13. Else, - b. Let A be ArrayCreate(len). - 14. ReturnIfAbrupt(A). - 15. Let k be 0. - 16. Repeat, while k < len - a. Let Pk be ToString(k). - b. Let kValue be Get(arrayLike, Pk). - c. ReturnIfAbrupt(kValue). - d. If mapping is true, then - i. Let mappedValue be Call(mapfn, T, «kValue, k»). - ... ----*/ - -var list = { - '0': 41, - '1': 42, - '2': 43, - length: 3 -}; -var calls = []; -var thisArg = {}; - -function mapFn (value) { - calls.push({ - args: arguments, - thisArg: this - }); - return value * 2; -} - -var result = Array.from(list, mapFn, thisArg); - -assert.sameValue(result.length, 3, 'result.length'); -assert.sameValue(result[0], 82, 'result[0]'); -assert.sameValue(result[1], 84, 'result[1]'); -assert.sameValue(result[2], 86, 'result[2]'); - -assert.sameValue(calls.length, 3, 'calls.length'); - -assert.sameValue(calls[0].args.length, 2, 'calls[0].args.length'); -assert.sameValue(calls[0].args[0], 41, 'calls[0].args[0]'); -assert.sameValue(calls[0].args[1], 0, 'calls[0].args[1]'); -assert.sameValue(calls[0].thisArg, thisArg, 'calls[0].thisArg'); - -assert.sameValue(calls[1].args.length, 2, 'calls[1].args.length'); -assert.sameValue(calls[1].args[0], 42, 'calls[1].args[0]'); -assert.sameValue(calls[1].args[1], 1, 'calls[1].args[1]'); -assert.sameValue(calls[1].thisArg, thisArg, 'calls[1].thisArg'); - -assert.sameValue(calls[2].args.length, 2, 'calls[2].args.length'); -assert.sameValue(calls[2].args[0], 43, 'calls[2].args[0]'); -assert.sameValue(calls[2].args[1], 2, 'calls[2].args[1]'); -assert.sameValue(calls[2].thisArg, thisArg, 'calls[2].thisArg'); +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +esid: sec-array.from +es6id: 22.1.2.1 +description: Calling from with a valid map function with thisArg +info: > + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + + ... + 10. Let len be ToLength(Get(arrayLike, "length")). + 11. ReturnIfAbrupt(len). + 12. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + 13. Else, + b. Let A be ArrayCreate(len). + 14. ReturnIfAbrupt(A). + 15. Let k be 0. + 16. Repeat, while k < len + a. Let Pk be ToString(k). + b. Let kValue be Get(arrayLike, Pk). + c. ReturnIfAbrupt(kValue). + d. If mapping is true, then + i. Let mappedValue be Call(mapfn, T, «kValue, k»). + ... +---*/ + +var list = { + '0': 41, + '1': 42, + '2': 43, + length: 3 +}; +var calls = []; +var thisArg = {}; + +function mapFn (value) { + calls.push({ + args: arguments, + thisArg: this + }); + return value * 2; +} + +var result = Array.from(list, mapFn, thisArg); + +assert.sameValue(result.length, 3, 'result.length'); +assert.sameValue(result[0], 82, 'result[0]'); +assert.sameValue(result[1], 84, 'result[1]'); +assert.sameValue(result[2], 86, 'result[2]'); + +assert.sameValue(calls.length, 3, 'calls.length'); + +assert.sameValue(calls[0].args.length, 2, 'calls[0].args.length'); +assert.sameValue(calls[0].args[0], 41, 'calls[0].args[0]'); +assert.sameValue(calls[0].args[1], 0, 'calls[0].args[1]'); +assert.sameValue(calls[0].thisArg, thisArg, 'calls[0].thisArg'); + +assert.sameValue(calls[1].args.length, 2, 'calls[1].args.length'); +assert.sameValue(calls[1].args[0], 42, 'calls[1].args[0]'); +assert.sameValue(calls[1].args[1], 1, 'calls[1].args[1]'); +assert.sameValue(calls[1].thisArg, thisArg, 'calls[1].thisArg'); + +assert.sameValue(calls[2].args.length, 2, 'calls[2].args.length'); +assert.sameValue(calls[2].args[0], 43, 'calls[2].args[0]'); +assert.sameValue(calls[2].args[1], 2, 'calls[2].args[1]'); +assert.sameValue(calls[2].thisArg, thisArg, 'calls[2].thisArg'); diff --git a/test/built-ins/Array/from/elements-added-after.js b/test/built-ins/Array/from/elements-added-after.js index 52fa034899d70c92ddd5ceb56131d6ea13828233..9aafe597ac2c8e1b9bdfd8990004659274e886a8 100644 --- a/test/built-ins/Array/from/elements-added-after.js +++ b/test/built-ins/Array/from/elements-added-after.js @@ -1,37 +1,38 @@ -// Copyright 2015 Microsoft Corporation. All rights reserved. -// This code is governed by the license found in the LICENSE file. - -/*--- -description: Elements added after the call to from -es6id: 22.1.2.1 ----*/ - -var arrayIndex = -1; -var originalLength = 7; -var obj = { - length: originalLength, - 0: 2, - 1: 4, - 2: 8, - 3: 16, - 4: 32, - 5: 64, - 6: 128 -}; -var array = [ 2, 4, 8, 16, 32, 64, 128 ]; -function mapFn(value, index) { - arrayIndex++; - assert.sameValue(value, obj[arrayIndex], "Value mismatch in mapFn at index " + index + "."); - assert.sameValue(index, arrayIndex, "Index mismatch in mapFn."); - obj[originalLength + arrayIndex] = 2 * arrayIndex + 1; - - return obj[arrayIndex]; -} - - -var a = Array.from(obj, mapFn); -assert.sameValue(a.length, array.length, "Length mismatch."); - -for (var j = 0; j < a.length; j++) { - assert.sameValue(a[j], array[j], "Element mismatch for array at index " + j + "."); -} +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Elements added after the call to from +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +var arrayIndex = -1; +var originalLength = 7; +var obj = { + length: originalLength, + 0: 2, + 1: 4, + 2: 8, + 3: 16, + 4: 32, + 5: 64, + 6: 128 +}; +var array = [ 2, 4, 8, 16, 32, 64, 128 ]; +function mapFn(value, index) { + arrayIndex++; + assert.sameValue(value, obj[arrayIndex], "Value mismatch in mapFn at index " + index + "."); + assert.sameValue(index, arrayIndex, "Index mismatch in mapFn."); + obj[originalLength + arrayIndex] = 2 * arrayIndex + 1; + + return obj[arrayIndex]; +} + + +var a = Array.from(obj, mapFn); +assert.sameValue(a.length, array.length, "Length mismatch."); + +for (var j = 0; j < a.length; j++) { + assert.sameValue(a[j], array[j], "Element mismatch for array at index " + j + "."); +} diff --git a/test/built-ins/Array/from/elements-deleted-after.js b/test/built-ins/Array/from/elements-deleted-after.js index 6edd6cd52100b47063bbbb6d38893e77d8eaad7f..d2d72e51e6fdacd896af5736940d2ce8e2d28bbd 100644 --- a/test/built-ins/Array/from/elements-deleted-after.js +++ b/test/built-ins/Array/from/elements-deleted-after.js @@ -1,31 +1,32 @@ -// 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 -es6id: 22.1.2.1 ----*/ - -var originalArray = [ 0, 1, -2, 4, -8, 16 ]; -var array = [ 0, 1, -2, 4, -8, 16 ]; -var a = []; -var arrayIndex = -1; -function mapFn(value, index) { - this.arrayIndex++; - assert.sameValue(value, array[this.arrayIndex], "Value mismatch in mapFn at index " + index + "."); - assert.sameValue(index, this.arrayIndex, "Index mismatch in mapFn."); - - array.splice(array.length - 1, 1); - return 127; -} - - -a = Array.from(array, mapFn, this); - -assert.sameValue(a.length, originalArray.length / 2, "Length mismatch. Old array : " + (originalArray.length / 2) + ". array : " + a.length + "."); - -for (var j = 0; j < originalArray.length / 2; j++) { - assert.sameValue(a[j], 127, "Element mismatch for mapped array at index " + j + "."); -} +// 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 +es6id: 22.1.2.1 +---*/ + +var originalArray = [ 0, 1, -2, 4, -8, 16 ]; +var array = [ 0, 1, -2, 4, -8, 16 ]; +var a = []; +var arrayIndex = -1; +function mapFn(value, index) { + this.arrayIndex++; + assert.sameValue(value, array[this.arrayIndex], "Value mismatch in mapFn at index " + index + "."); + assert.sameValue(index, this.arrayIndex, "Index mismatch in mapFn."); + + array.splice(array.length - 1, 1); + return 127; +} + + +a = Array.from(array, mapFn, this); + +assert.sameValue(a.length, originalArray.length / 2, "Length mismatch. Old array : " + (originalArray.length / 2) + ". array : " + a.length + "."); + +for (var j = 0; j < originalArray.length / 2; j++) { + assert.sameValue(a[j], 127, "Element mismatch for mapped array at index " + j + "."); +} diff --git a/test/built-ins/Array/from/elements-updated-after.js b/test/built-ins/Array/from/elements-updated-after.js index 7f475c6c0845a998e0b560d66a8502f173ed89f1..6c859e23accaa947bb85e903b366152ae1f0110e 100644 --- a/test/built-ins/Array/from/elements-updated-after.js +++ b/test/built-ins/Array/from/elements-updated-after.js @@ -1,26 +1,27 @@ -// Copyright 2015 Microsoft Corporation. All rights reserved. -// This code is governed by the license found in the LICENSE file. - -/*--- -description: Elements are updated after the call to from -es6id: 22.1.2.1 ----*/ - -var array = [ 127, 4, 8, 16, 32, 64, 128 ]; -var arrayIndex = -1; -function mapFn(value, index) { - arrayIndex++; - if (index + 1 < array.length) { - array[index + 1] = 127; - } - assert.sameValue(value, 127, "Value mismatch in mapFn at index " + index + "."); - assert.sameValue(index, arrayIndex, "Index mismatch in mapFn."); - - return value; -} - -var a = Array.from(array, mapFn); -assert.sameValue(a.length, array.length, "Length mismatch."); -for (var j = 0; j < a.length; j++) { - assert.sameValue(a[j], 127, "Element mismatch for mapped array."); -} +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Elements are updated after the call to from +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +var array = [ 127, 4, 8, 16, 32, 64, 128 ]; +var arrayIndex = -1; +function mapFn(value, index) { + arrayIndex++; + if (index + 1 < array.length) { + array[index + 1] = 127; + } + assert.sameValue(value, 127, "Value mismatch in mapFn at index " + index + "."); + assert.sameValue(index, arrayIndex, "Index mismatch in mapFn."); + + return value; +} + +var a = Array.from(array, mapFn); +assert.sameValue(a.length, array.length, "Length mismatch."); +for (var j = 0; j < a.length; j++) { + assert.sameValue(a[j], 127, "Element mismatch for mapped array."); +} diff --git a/test/built-ins/Array/from/from-array.js b/test/built-ins/Array/from/from-array.js index 7badf8e9f3b06ca2286663affe69a281484d61e9..59258bdae3c53a9d87556b556d819a70b56d4d9c 100644 --- a/test/built-ins/Array/from/from-array.js +++ b/test/built-ins/Array/from/from-array.js @@ -1,23 +1,24 @@ -// Copyright 2015 Microsoft Corporation. All rights reserved. -// This code is governed by the license found in the LICENSE file. - -/*--- -description: Passing a valid array -es6id: 22.1.2.1 ----*/ - -var array = [0, 'foo', , Infinity]; -var result = Array.from(array); - -assert.sameValue(result.length, 4, 'result.length'); -assert.sameValue(result[0], 0, 'result[0]'); -assert.sameValue(result[1], 'foo', 'result[1]'); -assert.sameValue(result[2], undefined, 'result[2]'); -assert.sameValue(result[3], Infinity, 'result[3]'); - -assert.notSameValue( - result, array, - 'result is not the object from items argument' -); - -assert(result instanceof Array, 'result instanceof Array'); +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Passing a valid array +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +var array = [0, 'foo', , Infinity]; +var result = Array.from(array); + +assert.sameValue(result.length, 4, 'result.length'); +assert.sameValue(result[0], 0, 'result[0]'); +assert.sameValue(result[1], 'foo', 'result[1]'); +assert.sameValue(result[2], undefined, 'result[2]'); +assert.sameValue(result[3], Infinity, 'result[3]'); + +assert.notSameValue( + result, array, + 'result is not the object from items argument' +); + +assert(result instanceof Array, 'result instanceof Array'); diff --git a/test/built-ins/Array/from/from-string.js b/test/built-ins/Array/from/from-string.js index bca1ff11ca290ce0ffa6376317b886ac95de5352..97ff33515e543167cbc77287d006fbb6f9910332 100644 --- a/test/built-ins/Array/from/from-string.js +++ b/test/built-ins/Array/from/from-string.js @@ -2,7 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -es6id: 22.1.2.1_T1 +esid: sec-array.from +es6id: 22.1.2.1 description: Testing Array.from when passed a String author: Hank Yates (hankyates@gmail.com) ---*/ diff --git a/test/built-ins/Array/from/get-iter-method-err.js b/test/built-ins/Array/from/get-iter-method-err.js index 745f1081358ebd06c79a434d7b5a674f3f6ace43..d7f5c084847e8ef05dc788deab4fd01f05a567cf 100644 --- a/test/built-ins/Array/from/get-iter-method-err.js +++ b/test/built-ins/Array/from/get-iter-method-err.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: Error accessing items' `Symbol.iterator` attribute info: > diff --git a/test/built-ins/Array/from/items-is-arraybuffer.js b/test/built-ins/Array/from/items-is-arraybuffer.js index f7800dcb77a1b9b4545770471c1b14e917a3c0b2..6c09f89568fb2a256cbf1b50f96b86931033fcc5 100644 --- a/test/built-ins/Array/from/items-is-arraybuffer.js +++ b/test/built-ins/Array/from/items-is-arraybuffer.js @@ -1,6 +1,7 @@ // Copyright 2015 Leonardo Balter. All rights reserved. // This code is governed by the license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: Return empty array if items argument is an ArrayBuffer info: > diff --git a/test/built-ins/Array/from/items-is-null-throws.js b/test/built-ins/Array/from/items-is-null-throws.js index be42873716e1e4354fbb2dff0849e824563dd974..d69783c5294eba235eabc5f9b86b2b97882a1473 100644 --- a/test/built-ins/Array/from/items-is-null-throws.js +++ b/test/built-ins/Array/from/items-is-null-throws.js @@ -1,6 +1,7 @@ // Copyright 2015 Leonardo Balter. All rights reserved. // This code is governed by the license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: Throws a TypeError if items argument is null info: > diff --git a/test/built-ins/Array/from/iter-adv-err.js b/test/built-ins/Array/from/iter-adv-err.js index 0b8259baebcb831ebb1de21c36bf783808ad504c..3fd82ac370b7da3280c356938cb8dc8ed7373a19 100644 --- a/test/built-ins/Array/from/iter-adv-err.js +++ b/test/built-ins/Array/from/iter-adv-err.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: Error advancing iterator info: > diff --git a/test/built-ins/Array/from/iter-cstm-ctor-err.js b/test/built-ins/Array/from/iter-cstm-ctor-err.js index 06733cb0939f15187bb0d34fafcfc9a56a857730..295c7879867d584099563894cd4b715201b12a15 100644 --- a/test/built-ins/Array/from/iter-cstm-ctor-err.js +++ b/test/built-ins/Array/from/iter-cstm-ctor-err.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: > Error creating object with custom constructor (traversed via iterator) diff --git a/test/built-ins/Array/from/iter-cstm-ctor.js b/test/built-ins/Array/from/iter-cstm-ctor.js index a19edeb9a3a93deded8dc0cb717191a497363b01..2f2086569873f2843b0599fbaa70438095a0ec04 100644 --- a/test/built-ins/Array/from/iter-cstm-ctor.js +++ b/test/built-ins/Array/from/iter-cstm-ctor.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: Creating object with custom constructor (traversed via iterator) info: > diff --git a/test/built-ins/Array/from/iter-get-iter-err.js b/test/built-ins/Array/from/iter-get-iter-err.js index edc5b1717e897a60476fc88a15353c3339c9726e..1dd19ada516f6b4684d4a48b79fe56af5ac53537 100644 --- a/test/built-ins/Array/from/iter-get-iter-err.js +++ b/test/built-ins/Array/from/iter-get-iter-err.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: Error creating iterator object info: > diff --git a/test/built-ins/Array/from/iter-get-iter-val-err.js b/test/built-ins/Array/from/iter-get-iter-val-err.js index 976981d52eb204df7ae6b23c13bce2144406f71d..0d3fedae32c417029ecc6689a184515868007ab6 100644 --- a/test/built-ins/Array/from/iter-get-iter-val-err.js +++ b/test/built-ins/Array/from/iter-get-iter-val-err.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: Error retrieving value of iterator result info: > diff --git a/test/built-ins/Array/from/iter-map-fn-args.js b/test/built-ins/Array/from/iter-map-fn-args.js index c7f35b8234498cbfe03e7891d020ce66c9349198..95d1caf3ab81a096f1a4a1ab9e804753c50ca2db 100644 --- a/test/built-ins/Array/from/iter-map-fn-args.js +++ b/test/built-ins/Array/from/iter-map-fn-args.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: > Arguments of mapping function (traversed via iterator) diff --git a/test/built-ins/Array/from/iter-map-fn-err.js b/test/built-ins/Array/from/iter-map-fn-err.js index a96b8f3c94e1ea3916c94cbeac95fe80944f4b31..6fbbf9475ab6feb045f350a8e48f5c6ae1cfa0b2 100644 --- a/test/built-ins/Array/from/iter-map-fn-err.js +++ b/test/built-ins/Array/from/iter-map-fn-err.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: Error invoking map function (traversed via iterator) info: > diff --git a/test/built-ins/Array/from/iter-map-fn-return.js b/test/built-ins/Array/from/iter-map-fn-return.js index ca4c8f37837c571dec9e55b44f2429c96ba9dc8a..083b256eacbc5eb58b1c66066b22a308be124adf 100644 --- a/test/built-ins/Array/from/iter-map-fn-return.js +++ b/test/built-ins/Array/from/iter-map-fn-return.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: Value returned by mapping function (traversed via iterator) info: > diff --git a/test/built-ins/Array/from/iter-map-fn-this-arg.js b/test/built-ins/Array/from/iter-map-fn-this-arg.js index 26becec78bc40832176c60ee7b302afc193abfd7..faafee820e4df16077616fa83f6c94b02e6c88e7 100644 --- a/test/built-ins/Array/from/iter-map-fn-this-arg.js +++ b/test/built-ins/Array/from/iter-map-fn-this-arg.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: > `this` value of mapping function with custom `this` argument (traversed via iterator) diff --git a/test/built-ins/Array/from/iter-map-fn-this-non-strict.js b/test/built-ins/Array/from/iter-map-fn-this-non-strict.js index c4e18eb029e9e41e278d0aa0140b0889f438a621..4294d5f8889ec920de93f1a1eceaf6ffb1327b79 100644 --- a/test/built-ins/Array/from/iter-map-fn-this-non-strict.js +++ b/test/built-ins/Array/from/iter-map-fn-this-non-strict.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: > `this` value of mapping function in non-strict mode (traversed via iterator) diff --git a/test/built-ins/Array/from/iter-map-fn-this-strict.js b/test/built-ins/Array/from/iter-map-fn-this-strict.js index bb17d90d816635d659f29596ce4a33442109c63b..fe39dc5dda75c409a72e068c36f176642fdb9e95 100644 --- a/test/built-ins/Array/from/iter-map-fn-this-strict.js +++ b/test/built-ins/Array/from/iter-map-fn-this-strict.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: > `this` value of mapping function in strict mode (traversed via iterator) diff --git a/test/built-ins/Array/from/iter-set-elem-prop-err.js b/test/built-ins/Array/from/iter-set-elem-prop-err.js index 64945a070dcb8a374ae400c493dc256bfb601f1f..a2d58860c036d0ffcb5ae7344fe3b39339ec152c 100644 --- a/test/built-ins/Array/from/iter-set-elem-prop-err.js +++ b/test/built-ins/Array/from/iter-set-elem-prop-err.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: Error setting property on result value (traversed via iterator) info: > diff --git a/test/built-ins/Array/from/iter-set-elem-prop.js b/test/built-ins/Array/from/iter-set-elem-prop.js index 91762fddde4920fd37e7abf5527d75c38ea9ee4e..331880b974e042cf25b7ca0d3c091863f3ff98fd 100644 --- a/test/built-ins/Array/from/iter-set-elem-prop.js +++ b/test/built-ins/Array/from/iter-set-elem-prop.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: Setting property on result value (traversed via iterator) info: > diff --git a/test/built-ins/Array/from/iter-set-length-err.js b/test/built-ins/Array/from/iter-set-length-err.js index 3379ed7ec4342cbfd424b6707779f3c96326732b..90a9d5d5c190c0eb30efcc9443dfb21c8cdfb7b7 100644 --- a/test/built-ins/Array/from/iter-set-length-err.js +++ b/test/built-ins/Array/from/iter-set-length-err.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: Error setting length of object (traversed via iterator) info: > diff --git a/test/built-ins/Array/from/iter-set-length.js b/test/built-ins/Array/from/iter-set-length.js index 95913df721d2d94149949069dacbbbd97ad1b8b6..13d456af86423777057ec4ca0ec7ff5123122875 100644 --- a/test/built-ins/Array/from/iter-set-length.js +++ b/test/built-ins/Array/from/iter-set-length.js @@ -1,6 +1,7 @@ // Copyright (C) 2015 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: Setting length of object (traversed via iterator) info: > diff --git a/test/built-ins/Array/from/mapfn-is-not-callable-typeerror.js b/test/built-ins/Array/from/mapfn-is-not-callable-typeerror.js index 07abecc5691d5a850179dadb22608baf830a1472..4ca28b1dd719547120d98ed61946a6e5c43b492e 100644 --- a/test/built-ins/Array/from/mapfn-is-not-callable-typeerror.js +++ b/test/built-ins/Array/from/mapfn-is-not-callable-typeerror.js @@ -1,34 +1,35 @@ -// Copyright 2015 Leonardo Balter. All rights reserved. -// This code is governed by the license found in the LICENSE file. -/*--- -es6id: 22.1.2.1 -description: Throws a TypeError if mapFn is not callable -info: > - 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) - - ... - 2. If mapfn is undefined, let mapping be false. - 3. else - a. If IsCallable(mapfn) is false, throw a TypeError exception. - ... ----*/ - -assert.throws(TypeError, function() { - Array.from([], null); -}); - -assert.throws(TypeError, function() { - Array.from([], {}); -}); - -assert.throws(TypeError, function() { - Array.from([], 'string'); -}); - -assert.throws(TypeError, function() { - Array.from([], true); -}); - -assert.throws(TypeError, function() { - Array.from([], 42); -}); +// Copyright 2015 Leonardo Balter. All rights reserved. +// This code is governed by the license found in the LICENSE file. +/*--- +esid: sec-array.from +es6id: 22.1.2.1 +description: Throws a TypeError if mapFn is not callable +info: > + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + + ... + 2. If mapfn is undefined, let mapping be false. + 3. else + a. If IsCallable(mapfn) is false, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + Array.from([], null); +}); + +assert.throws(TypeError, function() { + Array.from([], {}); +}); + +assert.throws(TypeError, function() { + Array.from([], 'string'); +}); + +assert.throws(TypeError, function() { + Array.from([], true); +}); + +assert.throws(TypeError, function() { + Array.from([], 42); +}); diff --git a/test/built-ins/Array/from/mapfn-is-symbol-throws.js b/test/built-ins/Array/from/mapfn-is-symbol-throws.js index 694ce5dfbe1e1e5c99a6f52f7c6a6a0ae20e6938..f6cf1071119e94f8fb71f348338d24f52b5fc7b6 100644 --- a/test/built-ins/Array/from/mapfn-is-symbol-throws.js +++ b/test/built-ins/Array/from/mapfn-is-symbol-throws.js @@ -1,6 +1,7 @@ // Copyright 2015 Leonardo Balter. All rights reserved. // This code is governed by the license found in the LICENSE file. /*--- +esid: sec-array.from es6id: 22.1.2.1 description: Throws a TypeError if mapFn is not callable (Symbol) info: > diff --git a/test/built-ins/Array/from/mapfn-throws-exception.js b/test/built-ins/Array/from/mapfn-throws-exception.js index 0e7fce659ce0360393ce7da9ba0e021561f7683c..a655126726e7102f9d52aa78747df289e5aaf9b2 100644 --- a/test/built-ins/Array/from/mapfn-throws-exception.js +++ b/test/built-ins/Array/from/mapfn-throws-exception.js @@ -1,14 +1,15 @@ -// Copyright 2015 Microsoft Corporation. All rights reserved. -// This code is governed by the license found in the LICENSE file. - -/*--- -description: mapFn throws an exception -es6id: 22.1.2.1 ----*/ - -var array = [ 2, 4, 8, 16, 32, 64, 128 ]; -function mapFn(value, index, obj) { - throw new Test262Error(); -} - -assert.throws(Test262Error, function(){Array.from(array, mapFn);}); +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: mapFn throws an exception +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +var array = [ 2, 4, 8, 16, 32, 64, 128 ]; +function mapFn(value, index, obj) { + throw new Test262Error(); +} + +assert.throws(Test262Error, function(){Array.from(array, mapFn);}); diff --git a/test/built-ins/Array/from/source-array-boundary.js b/test/built-ins/Array/from/source-array-boundary.js index 09ce928a6e1033d8daed2e01f5d15938238c22a2..4c0587a3203b676e29bb1b248af20e32f1ac9f11 100644 --- a/test/built-ins/Array/from/source-array-boundary.js +++ b/test/built-ins/Array/from/source-array-boundary.js @@ -1,26 +1,27 @@ -// Copyright 2015 Microsoft Corporation. All rights reserved. -// This code is governed by the license found in the LICENSE file. - -/*--- -description: Source array with boundary values -es6id: 22.1.2.1 ----*/ - -var array = [ Number.MAX_VALUE, Number.MIN_VALUE, Number.NaN, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY ]; -var arrayIndex = -1; -function mapFn(value, index) { - this.arrayIndex++; - assert.sameValue(value, array[this.arrayIndex], "Value mismatch in mapFn at index " + index + "."); - assert.sameValue(index, this.arrayIndex, "Index mismatch in mapFn."); - - return value; -} - -var a = Array.from(array, mapFn, this); - -assert.sameValue(a.length, array.length, "Length mismatch."); -assert.sameValue(a[0], Number.MAX_VALUE, "Element mismatch for mapped array at index 0."); -assert.sameValue(a[1], Number.MIN_VALUE, "Element mismatch for mapped array at index 1."); -assert.sameValue(a[2], Number.NaN, "Element mismatch for mapped array at index 2."); -assert.sameValue(a[3], Number.NEGATIVE_INFINITY, "Element mismatch for mapped array at index 3."); -assert.sameValue(a[4], Number.POSITIVE_INFINITY, "Element mismatch for mapped array at index 4."); +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Source array with boundary values +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +var array = [ Number.MAX_VALUE, Number.MIN_VALUE, Number.NaN, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY ]; +var arrayIndex = -1; +function mapFn(value, index) { + this.arrayIndex++; + assert.sameValue(value, array[this.arrayIndex], "Value mismatch in mapFn at index " + index + "."); + assert.sameValue(index, this.arrayIndex, "Index mismatch in mapFn."); + + return value; +} + +var a = Array.from(array, mapFn, this); + +assert.sameValue(a.length, array.length, "Length mismatch."); +assert.sameValue(a[0], Number.MAX_VALUE, "Element mismatch for mapped array at index 0."); +assert.sameValue(a[1], Number.MIN_VALUE, "Element mismatch for mapped array at index 1."); +assert.sameValue(a[2], Number.NaN, "Element mismatch for mapped array at index 2."); +assert.sameValue(a[3], Number.NEGATIVE_INFINITY, "Element mismatch for mapped array at index 3."); +assert.sameValue(a[4], Number.POSITIVE_INFINITY, "Element mismatch for mapped array at index 4."); diff --git a/test/built-ins/Array/from/source-object-constructor.js b/test/built-ins/Array/from/source-object-constructor.js index 2094766737512eee3a5160a22e65abafe8b4881a..225be5919cb54138a98ada057a7294d4ed082d01 100644 --- a/test/built-ins/Array/from/source-object-constructor.js +++ b/test/built-ins/Array/from/source-object-constructor.js @@ -1,10 +1,11 @@ -// Copyright 2015 Microsoft Corporation. All rights reserved. -// This code is governed by the license found in the LICENSE file. - -/*--- -description: > - Array.from uses a constructor other than Array. -es6id: 22.1.2.1 ----*/ - -assert.sameValue(Array.from.call(Object, []).constructor, Object); +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: > + Array.from uses a constructor other than Array. +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +assert.sameValue(Array.from.call(Object, []).constructor, Object); diff --git a/test/built-ins/Array/from/source-object-iterator-1.js b/test/built-ins/Array/from/source-object-iterator-1.js index d128a36fe29642c696811957cf44221cef2b4e0f..6c65e005f8cc414f51c06a9239f2c222f52149b0 100644 --- a/test/built-ins/Array/from/source-object-iterator-1.js +++ b/test/built-ins/Array/from/source-object-iterator-1.js @@ -1,28 +1,29 @@ -// Copyright 2015 Microsoft Corporation. All rights reserved. -// This code is governed by the license found in the LICENSE file. - -/*--- -description: Source object has iterator which throws -es6id: 22.1.2.1 ----*/ - -var array = [ 2, 4, 8, 16, 32, 64, 128 ]; -var obj = { - [Symbol.iterator]() { - return { - index: 0, - next() { - throw new Test262Error(); - }, - isDone : false, - get val() { - this.index++; - if (this.index > 7) { - this.isDone = true; - } - return 1 << this.index; - } - }; - } -}; -assert.throws(Test262Error, function(){Array.from(obj);}); +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Source object has iterator which throws +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +var array = [ 2, 4, 8, 16, 32, 64, 128 ]; +var obj = { + [Symbol.iterator]() { + return { + index: 0, + next() { + throw new Test262Error(); + }, + isDone : false, + get val() { + this.index++; + if (this.index > 7) { + this.isDone = true; + } + return 1 << this.index; + } + }; + } +}; +assert.throws(Test262Error, function(){Array.from(obj);}); diff --git a/test/built-ins/Array/from/source-object-iterator-2.js b/test/built-ins/Array/from/source-object-iterator-2.js index ff8e804045548e9f1255cd99754684b7b1f75bb3..0245c2b5fb4e79e729e6979ce5e89c580d1d220f 100644 --- a/test/built-ins/Array/from/source-object-iterator-2.js +++ b/test/built-ins/Array/from/source-object-iterator-2.js @@ -1,35 +1,36 @@ -// Copyright 2015 Microsoft Corporation. All rights reserved. -// This code is governed by the license found in the LICENSE file. - -/*--- -description: Source object has iterator -es6id: 22.1.2.1 ----*/ - -var array = [ 2, 4, 8, 16, 32, 64, 128 ]; -var obj = { - [Symbol.iterator]() { - return { - index: 0, - next() { - return { - value: this.val, - done: this.isDone - }; - }, - isDone : false, - get val() { - this.index++; - if (this.index > 7) { - this.isDone = true; - } - return 1 << this.index; - } - }; - } -}; -var a = Array.from.call(Object, obj); -assert.sameValue(typeof a, typeof {}, "The returned type is expected to be object."); -for (var j = 0; j < a.length; j++) { - assert.sameValue(a[j], array[j], "Elements mismatch at " + j + "."); -} +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Source object has iterator +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +var array = [ 2, 4, 8, 16, 32, 64, 128 ]; +var obj = { + [Symbol.iterator]() { + return { + index: 0, + next() { + return { + value: this.val, + done: this.isDone + }; + }, + isDone : false, + get val() { + this.index++; + if (this.index > 7) { + this.isDone = true; + } + return 1 << this.index; + } + }; + } +}; +var a = Array.from.call(Object, obj); +assert.sameValue(typeof a, typeof {}, "The returned type is expected to be object."); +for (var j = 0; j < a.length; j++) { + assert.sameValue(a[j], array[j], "Elements mismatch at " + j + "."); +} diff --git a/test/built-ins/Array/from/source-object-length.js b/test/built-ins/Array/from/source-object-length.js index b320affa8a994093b814c071bde2813b1cf0ef43..75c46dfc4ba6dbf8fc89b1125f50cd0a2bd78820 100644 --- a/test/built-ins/Array/from/source-object-length.js +++ b/test/built-ins/Array/from/source-object-length.js @@ -1,24 +1,25 @@ -// Copyright 2015 Microsoft Corporation. All rights reserved. -// This code is governed by the license found in the LICENSE file. - -/*--- -description: > - Source is an object with length property and one item is deleted - from the source -es6id: 22.1.2.1 ----*/ - -var array = [2, 4, 0, 16]; -var expectedArray = [2, 4, , 16]; -var obj = { - length : 4, - 0 : 2, - 1 : 4, - 2 : 0, - 3 : 16 -}; -delete obj[2]; -var a = Array.from(obj); -for (var j = 0; j < expectedArray.length; j++) { - assert.sameValue(a[j], expectedArray[j], "Elements mismatch at " + j + "."); -} +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: > + Source is an object with length property and one item is deleted + from the source +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +var array = [2, 4, 0, 16]; +var expectedArray = [2, 4, , 16]; +var obj = { + length : 4, + 0 : 2, + 1 : 4, + 2 : 0, + 3 : 16 +}; +delete obj[2]; +var a = Array.from(obj); +for (var j = 0; j < expectedArray.length; j++) { + assert.sameValue(a[j], expectedArray[j], "Elements mismatch at " + j + "."); +} diff --git a/test/built-ins/Array/from/source-object-missing.js b/test/built-ins/Array/from/source-object-missing.js index fd2a4a95106bbfb33f5971ebfacbdffcea341677..ad5a6055dc7ed755f0b25172b1c908f8e74e7ba9 100644 --- a/test/built-ins/Array/from/source-object-missing.js +++ b/test/built-ins/Array/from/source-object-missing.js @@ -1,21 +1,22 @@ -// Copyright 2015 Microsoft Corporation. All rights reserved. -// This code is governed by the license found in the LICENSE file. - -/*--- -description: Source is an object with missing values -es6id: 22.1.2.1 ----*/ - -var array = [2, 4, , 16]; -var obj = { - length: 4, - 0: 2, - 1: 4, - 3: 16 -}; - -var a = Array.from.call(Object, obj); -assert.sameValue(typeof a, "object", "The returned type is expected to be object."); -for (var j = 0; j < a.length; j++) { - assert.sameValue(a[j], array[j], "Elements mismatch at " + j + "."); -} +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Source is an object with missing values +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +var array = [2, 4, , 16]; +var obj = { + length: 4, + 0: 2, + 1: 4, + 3: 16 +}; + +var a = Array.from.call(Object, obj); +assert.sameValue(typeof a, "object", "The returned type is expected to be object."); +for (var j = 0; j < a.length; j++) { + assert.sameValue(a[j], array[j], "Elements mismatch at " + j + "."); +} diff --git a/test/built-ins/Array/from/source-object-without.js b/test/built-ins/Array/from/source-object-without.js index 2f6018ed7a8e21a893446be2ce60f2f55794f191..96ec31c25a7258729905399f28007ba8142f79f4 100644 --- a/test/built-ins/Array/from/source-object-without.js +++ b/test/built-ins/Array/from/source-object-without.js @@ -1,17 +1,18 @@ -// Copyright 2015 Microsoft Corporation. All rights reserved. -// This code is governed by the license found in the LICENSE file. - -/*--- -description: Source is an object without length property -es6id: 22.1.2.1 ----*/ - -var obj = { - 0: 2, - 1: 4, - 2: 8, - 3: 16 -} - -var a = Array.from(obj); -assert.sameValue(a.length, 0, "Expected an array of length 0."); +// Copyright 2015 Microsoft Corporation. All rights reserved. +// This code is governed by the license found in the LICENSE file. + +/*--- +description: Source is an object without length property +esid: sec-array.from +es6id: 22.1.2.1 +---*/ + +var obj = { + 0: 2, + 1: 4, + 2: 8, + 3: 16 +} + +var a = Array.from(obj); +assert.sameValue(a.length, 0, "Expected an array of length 0."); diff --git a/test/built-ins/Array/from/this-null.js b/test/built-ins/Array/from/this-null.js index 90efd6fe87103a4ecf03e6d07b0d3655861526b2..c0fa8be227e612c4df0801e15e093a59433fff6e 100644 --- a/test/built-ins/Array/from/this-null.js +++ b/test/built-ins/Array/from/this-null.js @@ -1,11 +1,12 @@ -// Copyright 2015 Leonardo Balter. All rights reserved. -// This code is governed by the license found in the LICENSE file. -/*--- -es6id: 22.1.2.1 -description: Does not throw if this is null ----*/ - -var result = Array.from.call(null, []); - -assert(result instanceof Array, 'Does not throw if this is null'); -assert.sameValue(result.length, 0, 'result.length'); +// Copyright 2015 Leonardo Balter. All rights reserved. +// This code is governed by the license found in the LICENSE file. +/*--- +esid: sec-array.from +es6id: 22.1.2.1 +description: Does not throw if this is null +---*/ + +var result = Array.from.call(null, []); + +assert(result instanceof Array, 'Does not throw if this is null'); +assert.sameValue(result.length, 0, 'result.length');