From b07621ded117a0b1a57dd67bf6a15be1e45103ce Mon Sep 17 00:00:00 2001 From: Sue Lockwood <deathbear.apache@gmail.com> Date: Tue, 27 Jun 2017 14:12:06 -0700 Subject: [PATCH] update Array/From files ESID to sec-array.from (#1077) --- .../Array/from/Array.from-descriptor.js | 1 + test/built-ins/Array/from/Array.from-name.js | 1 + test/built-ins/Array/from/Array.from_arity.js | 1 + ...ay.from_forwards-length-for-array-likes.js | 1 + .../from/calling-from-valid-1-noStrict.js | 133 ++++++++--------- .../from/calling-from-valid-1-onlyStrict.js | 133 ++++++++--------- .../Array/from/calling-from-valid-2.js | 135 +++++++++--------- .../Array/from/elements-added-after.js | 75 +++++----- .../Array/from/elements-deleted-after.js | 63 ++++---- .../Array/from/elements-updated-after.js | 53 +++---- test/built-ins/Array/from/from-array.js | 47 +++--- test/built-ins/Array/from/from-string.js | 3 +- .../Array/from/get-iter-method-err.js | 1 + .../Array/from/items-is-arraybuffer.js | 1 + .../Array/from/items-is-null-throws.js | 1 + test/built-ins/Array/from/iter-adv-err.js | 1 + .../Array/from/iter-cstm-ctor-err.js | 1 + test/built-ins/Array/from/iter-cstm-ctor.js | 1 + .../built-ins/Array/from/iter-get-iter-err.js | 1 + .../Array/from/iter-get-iter-val-err.js | 1 + test/built-ins/Array/from/iter-map-fn-args.js | 1 + test/built-ins/Array/from/iter-map-fn-err.js | 1 + .../Array/from/iter-map-fn-return.js | 1 + .../Array/from/iter-map-fn-this-arg.js | 1 + .../Array/from/iter-map-fn-this-non-strict.js | 1 + .../Array/from/iter-map-fn-this-strict.js | 1 + .../Array/from/iter-set-elem-prop-err.js | 1 + .../Array/from/iter-set-elem-prop.js | 1 + .../Array/from/iter-set-length-err.js | 1 + test/built-ins/Array/from/iter-set-length.js | 1 + .../from/mapfn-is-not-callable-typeerror.js | 69 ++++----- .../Array/from/mapfn-is-symbol-throws.js | 1 + .../Array/from/mapfn-throws-exception.js | 29 ++-- .../Array/from/source-array-boundary.js | 53 +++---- .../Array/from/source-object-constructor.js | 21 +-- .../Array/from/source-object-iterator-1.js | 57 ++++---- .../Array/from/source-object-iterator-2.js | 71 ++++----- .../Array/from/source-object-length.js | 49 +++---- .../Array/from/source-object-missing.js | 43 +++--- .../Array/from/source-object-without.js | 35 ++--- test/built-ins/Array/from/this-null.js | 23 +-- 41 files changed, 578 insertions(+), 537 deletions(-) diff --git a/test/built-ins/Array/from/Array.from-descriptor.js b/test/built-ins/Array/from/Array.from-descriptor.js index 7fcb331e09..38778287b6 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 cb05ac2b5d..add03df6c5 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 85f53379ce..ad5e8a6aae 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 8c946efd40..5b3491a4bf 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 c2b351e2ff..81f419cbb9 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 7b2e603b2c..e794e6ea4a 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 7ae61c8ebf..9831ec5e47 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 52fa034899..9aafe597ac 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 6edd6cd521..d2d72e51e6 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 7f475c6c08..6c859e23ac 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 7badf8e9f3..59258bdae3 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 bca1ff11ca..97ff33515e 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 745f108135..d7f5c08484 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 f7800dcb77..6c09f89568 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 be42873716..d69783c529 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 0b8259baeb..3fd82ac370 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 06733cb093..295c787986 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 a19edeb9a3..2f20865698 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 edc5b1717e..1dd19ada51 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 976981d52e..0d3fedae32 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 c7f35b8234..95d1caf3ab 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 a96b8f3c94..6fbbf9475a 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 ca4c8f3783..083b256eac 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 26becec78b..faafee820e 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 c4e18eb029..4294d5f888 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 bb17d90d81..fe39dc5dda 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 64945a070d..a2d58860c0 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 91762fddde..331880b974 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 3379ed7ec4..90a9d5d5c1 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 95913df721..13d456af86 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 07abecc569..4ca28b1dd7 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 694ce5dfbe..f6cf107111 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 0e7fce659c..a655126726 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 09ce928a6e..4c0587a320 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 2094766737..225be5919c 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 d128a36fe2..6c65e005f8 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 ff8e804045..0245c2b5fb 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 b320affa8a..75c46dfc4b 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 fd2a4a9510..ad5a6055dc 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 2f6018ed7a..96ec31c25a 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 90efd6fe87..c0fa8be227 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'); -- GitLab