diff --git a/test/built-ins/Object/fromEntries/empty-iterable.js b/test/built-ins/Object/fromEntries/empty-iterable.js index 0ba1b950db4d83a7b04bfd22beae5d640e751d50..3e67be7351a3891348a378f4b0857541c536d942 100644 --- a/test/built-ins/Object/fromEntries/empty-iterable.js +++ b/test/built-ins/Object/fromEntries/empty-iterable.js @@ -2,8 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: When given an empty list, makes an empty object. esid: sec-object.fromentries +description: When given an empty list, makes an empty object. +info: | + Object.fromEntries ( iterable ) + + ... + 4. Let stepsDefine be the algorithm steps defined in CreateDataPropertyOnObject Functions. + 5. Let adder be CreateBuiltinFunction(stepsDefine, « »). + 6. Return ? AddEntriesFromIterable(obj, iterable, adder). + features: [Object.fromEntries] ---*/ diff --git a/test/built-ins/Object/fromEntries/evaluation-order.js b/test/built-ins/Object/fromEntries/evaluation-order.js index 4c9e07a4cb4ec1e74ea30dc7ab44bd2a8eac21ed..ef1492e36c3a63f8c174d9c49298dac360c8b507 100644 --- a/test/built-ins/Object/fromEntries/evaluation-order.js +++ b/test/built-ins/Object/fromEntries/evaluation-order.js @@ -2,8 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Evaluation order is iterator.next(), get '0', get '1', toPropertyKey, repeat. esid: sec-object.fromentries +description: Evaluation order is iterator.next(), get '0', get '1', toPropertyKey, repeat. +info: | + Object.fromEntries ( iterable ) + + ... + 4. Let stepsDefine be the algorithm steps defined in CreateDataPropertyOnObject Functions. + 5. Let adder be CreateBuiltinFunction(stepsDefine, « »). + 6. Return ? AddEntriesFromIterable(obj, iterable, adder). + includes: [compareArray.js] features: [Symbol.iterator, Object.fromEntries] ---*/ diff --git a/test/built-ins/Object/fromEntries/iterator-closed-for-null-entry.js.js b/test/built-ins/Object/fromEntries/iterator-closed-for-null-entry.js similarity index 62% rename from test/built-ins/Object/fromEntries/iterator-closed-for-null-entry.js.js rename to test/built-ins/Object/fromEntries/iterator-closed-for-null-entry.js index b84d87feacd2e86ca15498aea131df38b98383bb..6907a65cadedbcac1ecf41b9e7ff561ec27f70a2 100644 --- a/test/built-ins/Object/fromEntries/iterator-closed-for-null-entry.js.js +++ b/test/built-ins/Object/fromEntries/iterator-closed-for-null-entry.js @@ -2,8 +2,25 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Closes iterators when they return entries which are null. esid: sec-object.fromentries +description: Closes iterators when they return entries which are null. +info: | + Object.fromEntries ( iterable ) + + ... + 4. Let stepsDefine be the algorithm steps defined in CreateDataPropertyOnObject Functions. + 5. Let adder be CreateBuiltinFunction(stepsDefine, « »). + 6. Return ? AddEntriesFromIterable(obj, iterable, adder). + + AddEntriesFromIterable ( target, iterable, adder ) + + ... + 4. Repeat, + ... + d. If Type(nextItem) is not Object, then + i. Let error be ThrowCompletion(a newly created TypeError object). + ii. Return ? IteratorClose(iteratorRecord, error). + features: [Symbol.iterator, Object.fromEntries] ---*/ @@ -19,7 +36,7 @@ var iterable = { advanced = true; return { done: false, - value: 'null', + value: null, }; }, return: function() { diff --git a/test/built-ins/Object/fromEntries/iterator-closed-for-string-entry.js.js b/test/built-ins/Object/fromEntries/iterator-closed-for-string-entry.js similarity index 64% rename from test/built-ins/Object/fromEntries/iterator-closed-for-string-entry.js.js rename to test/built-ins/Object/fromEntries/iterator-closed-for-string-entry.js index b0c5bc9f9098be28cda26f0d9408803e0cb7f2e8..81a27e0731b2b0a46000cd72403268bb9f541a57 100644 --- a/test/built-ins/Object/fromEntries/iterator-closed-for-string-entry.js.js +++ b/test/built-ins/Object/fromEntries/iterator-closed-for-string-entry.js @@ -2,8 +2,25 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Closes iterators when they return entries which are strings. esid: sec-object.fromentries +description: Closes iterators when they return entries which are strings. +info: | + Object.fromEntries ( iterable ) + + ... + 4. Let stepsDefine be the algorithm steps defined in CreateDataPropertyOnObject Functions. + 5. Let adder be CreateBuiltinFunction(stepsDefine, « »). + 6. Return ? AddEntriesFromIterable(obj, iterable, adder). + + AddEntriesFromIterable ( target, iterable, adder ) + + ... + 4. Repeat, + ... + d. If Type(nextItem) is not Object, then + i. Let error be ThrowCompletion(a newly created TypeError object). + ii. Return ? IteratorClose(iteratorRecord, error). + features: [Symbol.iterator, Object.fromEntries] ---*/ diff --git a/test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-accessor.js b/test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-key-accessor.js similarity index 65% rename from test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-accessor.js rename to test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-key-accessor.js index 9e7f9e4a2cfa961f51954c6c45305b73425aad55..e042da46da63e8d98d5b9531dc3c385ccc209db5 100644 --- a/test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-accessor.js +++ b/test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-key-accessor.js @@ -2,8 +2,24 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Closes iterators when accessing an entry's properties throws. esid: sec-object.fromentries +description: Closes iterators when accessing an entry's key throws. +info: | + Object.fromEntries ( iterable ) + + ... + 4. Let stepsDefine be the algorithm steps defined in CreateDataPropertyOnObject Functions. + 5. Let adder be CreateBuiltinFunction(stepsDefine, « »). + 6. Return ? AddEntriesFromIterable(obj, iterable, adder). + + AddEntriesFromIterable ( target, iterable, adder ) + + ... + 4. Repeat, + ... + e. Let k be Get(nextItem, "0"). + f. If k is an abrupt completion, return ? IteratorClose(iteratorRecord, k). + features: [Symbol.iterator, Object.fromEntries] ---*/ diff --git a/test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-key-tostring.js b/test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-key-tostring.js index 5a845b5b20657e87394db529b023b099d88561ec..a7ccfae51ec7690205c6f71be764b5222fb7d076 100644 --- a/test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-key-tostring.js +++ b/test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-key-tostring.js @@ -2,8 +2,24 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Closes iterators when toString on a key throws. esid: sec-object.fromentries +description: Closes iterators when toString on a key throws. +info: | + Object.fromEntries ( iterable ) + + ... + 4. Let stepsDefine be the algorithm steps defined in CreateDataPropertyOnObject Functions. + 5. Let adder be CreateBuiltinFunction(stepsDefine, « »). + 6. Return ? AddEntriesFromIterable(obj, iterable, adder). + + AddEntriesFromIterable ( target, iterable, adder ) + + ... + 4. Repeat, + ... + e. Let k be Get(nextItem, "0"). + f. If k is an abrupt completion, return ? IteratorClose(iteratorRecord, k). + features: [Symbol.iterator, Object.fromEntries] ---*/ diff --git a/test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-value-accessor.js b/test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-value-accessor.js new file mode 100644 index 0000000000000000000000000000000000000000..b75139a0940973e6c95e682221055d7d5678d60d --- /dev/null +++ b/test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-value-accessor.js @@ -0,0 +1,64 @@ +// Copyright (C) 2018 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.fromentries +description: Closes iterators when accessing an entry's value throws. +info: | + Object.fromEntries ( iterable ) + + ... + 4. Let stepsDefine be the algorithm steps defined in CreateDataPropertyOnObject Functions. + 5. Let adder be CreateBuiltinFunction(stepsDefine, « »). + 6. Return ? AddEntriesFromIterable(obj, iterable, adder). + + AddEntriesFromIterable ( target, iterable, adder ) + + ... + 4. Repeat, + ... + g. Let v be Get(nextItem, "1"). + h. If v is an abrupt completion, return ? IteratorClose(iteratorRecord, v). + +features: [Symbol.iterator, Object.fromEntries] +---*/ + +function DummyError() {} + +var returned = false; +var iterable = { + [Symbol.iterator]: function() { + var advanced = false; + return { + next: function() { + if (advanced) { + throw new Test262Error('should only advance once'); + } + advanced = true; + return { + done: false, + value: { + get '0'() { + return 'key'; + }, + get '1'() { + throw new DummyError(); + }, + }, + }; + }, + return: function() { + if (returned) { + throw new Test262Error('should only return once'); + } + returned = true; + }, + }; + }, +}; + +assert.throws(DummyError, function() { + Object.fromEntries(iterable); +}); + +assert(returned, 'iterator should be closed when entry value property access throws'); diff --git a/test/built-ins/Object/fromEntries/iterator-not-closed-for-next-returning-non-object.js b/test/built-ins/Object/fromEntries/iterator-not-closed-for-next-returning-non-object.js index 8f18c974f04f70af3e235c14515ee69ca8ed6bbd..fba4fbe67e169127195b223753957d9ff50523f9 100644 --- a/test/built-ins/Object/fromEntries/iterator-not-closed-for-next-returning-non-object.js +++ b/test/built-ins/Object/fromEntries/iterator-not-closed-for-next-returning-non-object.js @@ -2,8 +2,33 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Does not close iterators with a `next` method which returns a non-object. esid: sec-object.fromentries +description: Does not close iterators with a `next` method which returns a non-object. +info: | + Object.fromEntries ( iterable ) + + ... + 4. Let stepsDefine be the algorithm steps defined in CreateDataPropertyOnObject Functions. + 5. Let adder be CreateBuiltinFunction(stepsDefine, « »). + 6. Return ? AddEntriesFromIterable(obj, iterable, adder). + + AddEntriesFromIterable ( target, iterable, adder ) + + ... + 4. Repeat, + a. Let next be ? IteratorStep(iteratorRecord). + + + IteratorStep ( iteratorRecord ) + + 1. Let result be ? IteratorNext(iteratorRecord). + + + IteratorNext ( iteratorRecord [ , value ] ) + + ... + 3. If Type(result) is not Object, throw a TypeError exception. + features: [Symbol.iterator, Object.fromEntries] ---*/ diff --git a/test/built-ins/Object/fromEntries/iterator-not-closed-for-throwing-done-accessor.js b/test/built-ins/Object/fromEntries/iterator-not-closed-for-throwing-done-accessor.js index 5fd69c116f06e051e38e59a70fd133f1d149118f..f0d2c0833ebd676eb8e8d9645515a0d171f3619f 100644 --- a/test/built-ins/Object/fromEntries/iterator-not-closed-for-throwing-done-accessor.js +++ b/test/built-ins/Object/fromEntries/iterator-not-closed-for-throwing-done-accessor.js @@ -2,8 +2,33 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Does not close iterators with a `done` accessor which throws. esid: sec-object.fromentries +description: Does not close iterators with a `done` accessor which throws. +info: | + Object.fromEntries ( iterable ) + + ... + 4. Let stepsDefine be the algorithm steps defined in CreateDataPropertyOnObject Functions. + 5. Let adder be CreateBuiltinFunction(stepsDefine, « »). + 6. Return ? AddEntriesFromIterable(obj, iterable, adder). + + AddEntriesFromIterable ( target, iterable, adder ) + + ... + 4. Repeat, + a. Let next be ? IteratorStep(iteratorRecord). + + + IteratorStep ( iteratorRecord ) + + 1. Let result be ? IteratorNext(iteratorRecord). + + + IteratorNext ( iteratorRecord [ , value ] ) + + ... + 3. If Type(result) is not Object, throw a TypeError exception. + features: [Symbol.iterator, Object.fromEntries] ---*/ diff --git a/test/built-ins/Object/fromEntries/iterator-not-closed-for-throwing-next.js b/test/built-ins/Object/fromEntries/iterator-not-closed-for-throwing-next.js index b5ebcdf3f1505d5c458e5f9cdf9d0e1818d542c6..cbb2afaa91b164c082309214fdc70ef17cc05a89 100644 --- a/test/built-ins/Object/fromEntries/iterator-not-closed-for-throwing-next.js +++ b/test/built-ins/Object/fromEntries/iterator-not-closed-for-throwing-next.js @@ -2,8 +2,33 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Does not close iterators with a `next` method which throws. esid: sec-object.fromentries +description: Does not close iterators with a `next` method which throws. +info: | + Object.fromEntries ( iterable ) + + ... + 4. Let stepsDefine be the algorithm steps defined in CreateDataPropertyOnObject Functions. + 5. Let adder be CreateBuiltinFunction(stepsDefine, « »). + 6. Return ? AddEntriesFromIterable(obj, iterable, adder). + + AddEntriesFromIterable ( target, iterable, adder ) + + ... + 4. Repeat, + a. Let next be ? IteratorStep(iteratorRecord). + + + IteratorStep ( iteratorRecord ) + + 1. Let result be ? IteratorNext(iteratorRecord). + + + IteratorNext ( iteratorRecord [ , value ] ) + + ... + 3. If Type(result) is not Object, throw a TypeError exception. + features: [Symbol.iterator, Object.fromEntries] ---*/ diff --git a/test/built-ins/Object/fromEntries/iterator-not-closed-for-uncallable-next.js b/test/built-ins/Object/fromEntries/iterator-not-closed-for-uncallable-next.js index f9aa9d23e1038c99d3ef008d2a5a63b9c58da5a9..74ad7a739caccc461919f553e4001401de2be337 100644 --- a/test/built-ins/Object/fromEntries/iterator-not-closed-for-uncallable-next.js +++ b/test/built-ins/Object/fromEntries/iterator-not-closed-for-uncallable-next.js @@ -2,8 +2,26 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Does not close iterators with an uncallable `next` property. esid: sec-object.fromentries +description: Does not close iterators with an uncallable `next` property. +info: | + Object.fromEntries ( iterable ) + + ... + 4. Let stepsDefine be the algorithm steps defined in CreateDataPropertyOnObject Functions. + 5. Let adder be CreateBuiltinFunction(stepsDefine, « »). + 6. Return ? AddEntriesFromIterable(obj, iterable, adder). + + AddEntriesFromIterable ( target, iterable, adder ) + + ... + 4. Repeat, + a. Let next be ? IteratorStep(iteratorRecord). + + + IteratorStep ( iteratorRecord ) + + 1. Let result be ? IteratorNext(iteratorRecord). features: [Symbol.iterator, Object.fromEntries] ---*/ diff --git a/test/built-ins/Object/fromEntries/length.js b/test/built-ins/Object/fromEntries/length.js index 56615b4d7b8d0e20a6078018fa5ab531d874ee6a..f47c7ba18938b622df4d0c76f5baeca76f75c56a 100644 --- a/test/built-ins/Object/fromEntries/length.js +++ b/test/built-ins/Object/fromEntries/length.js @@ -8,8 +8,9 @@ includes: [propertyHelper.js] features: [Object.fromEntries] ---*/ -assert.sameValue(Object.fromEntries.length, 1); - -verifyNotEnumerable(Object.fromEntries, "length"); -verifyNotWritable(Object.fromEntries, "length"); -verifyConfigurable(Object.fromEntries, "length"); +verifyProperty(Object.fromEntries, "length", { + value: 1, + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/built-ins/Object/fromEntries/name.js b/test/built-ins/Object/fromEntries/name.js index aa39c2277dd419de14d6b0d797cb67fb94c3e040..c39ea095687a30e80530f3579de26c6b9209ae07 100644 --- a/test/built-ins/Object/fromEntries/name.js +++ b/test/built-ins/Object/fromEntries/name.js @@ -8,8 +8,9 @@ includes: [propertyHelper.js] features: [Object.fromEntries] ---*/ -assert.sameValue(Object.fromEntries.name, "fromEntries"); - -verifyNotEnumerable(Object.fromEntries, "name"); -verifyNotWritable(Object.fromEntries, "name"); -verifyConfigurable(Object.fromEntries, "name"); +verifyProperty(Object.fromEntries, "name", { + value: "fromEntries", + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/built-ins/Object/fromEntries/requires-argument.js b/test/built-ins/Object/fromEntries/requires-argument.js index b65051b00395fc9cea98f317fd3707f2ba142308..19b91a53073bacb001080aca69e619d548bbce7d 100644 --- a/test/built-ins/Object/fromEntries/requires-argument.js +++ b/test/built-ins/Object/fromEntries/requires-argument.js @@ -2,8 +2,15 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -description: Throws when called without an argument. esid: sec-object.fromentries +description: Throws when called without an argument. +info: | + + Object.fromEntries ( iterable ) + + 1. Perform ? RequireObjectCoercible(iterable). + ... + features: [Object.fromEntries] ---*/ diff --git a/test/built-ins/Object/fromEntries/simple-properties.js b/test/built-ins/Object/fromEntries/simple-properties.js index 92663304bafb1d4430a715c72e6876fe95d0ed1b..31f0f388d7ad9d7318f3b6a94d11036e35b2aec1 100644 --- a/test/built-ins/Object/fromEntries/simple-properties.js +++ b/test/built-ins/Object/fromEntries/simple-properties.js @@ -9,6 +9,8 @@ features: [Object.fromEntries] ---*/ var result = Object.fromEntries([['key', 'value']]); -verifyEnumerable(result, 'key'); -verifyWritable(result, 'key'); -verifyConfigurable(result, 'key'); +verifyProperty(result, "key", { + enumerable: true, + writable: true, + configurable: true, +}); diff --git a/test/built-ins/Object/fromEntries/string-entry-string-object-succeeds.js b/test/built-ins/Object/fromEntries/string-entry-string-object-succeeds.js new file mode 100644 index 0000000000000000000000000000000000000000..a29e508b65247cbe98b09adc8391b0c596e0e087 --- /dev/null +++ b/test/built-ins/Object/fromEntries/string-entry-string-object-succeeds.js @@ -0,0 +1,11 @@ +// Copyright (C) 2018 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Succeeds when an entry object is a boxed string. +esid: sec-object.fromentries +features: [Object.fromEntries] +---*/ + +var result = Object.fromEntries([new String('ab')]); +assert.sameValue(result['a'], 'b');