From ff475fce11f19172f255b64a10843d49a108998a Mon Sep 17 00:00:00 2001
From: Rick Waldron <waldron.rick@gmail.com>
Date: Mon, 13 Aug 2018 12:44:09 -0400
Subject: [PATCH] Object.fromEntries: use verifyProperty; add specification
 details

---
 .../Object/fromEntries/empty-iterable.js      | 10 ++-
 .../Object/fromEntries/evaluation-order.js    | 10 ++-
 .../iterator-closed-for-null-entry.js         | 21 +++++-
 .../iterator-closed-for-string-entry.js       | 19 +++++-
 ...closed-for-throwing-entry-key-accessor.js} | 18 +++++-
 ...-closed-for-throwing-entry-key-tostring.js | 18 +++++-
 ...losed-for-throwing-entry-value-accessor.js | 64 +++++++++++++++++++
 ...ot-closed-for-next-returning-non-object.js | 27 +++++++-
 ...r-not-closed-for-throwing-done-accessor.js | 27 +++++++-
 .../iterator-not-closed-for-throwing-next.js  | 27 +++++++-
 ...iterator-not-closed-for-uncallable-next.js | 20 +++++-
 test/built-ins/Object/fromEntries/length.js   | 11 ++--
 test/built-ins/Object/fromEntries/name.js     | 11 ++--
 .../Object/fromEntries/requires-argument.js   |  9 ++-
 .../Object/fromEntries/simple-properties.js   |  8 ++-
 .../string-entry-string-object-succeeds.js    | 11 ++++
 16 files changed, 286 insertions(+), 25 deletions(-)
 rename test/built-ins/Object/fromEntries/{iterator-closed-for-throwing-entry-accessor.js => iterator-closed-for-throwing-entry-key-accessor.js} (65%)
 create mode 100644 test/built-ins/Object/fromEntries/iterator-closed-for-throwing-entry-value-accessor.js
 create mode 100644 test/built-ins/Object/fromEntries/string-entry-string-object-succeeds.js

diff --git a/test/built-ins/Object/fromEntries/empty-iterable.js b/test/built-ins/Object/fromEntries/empty-iterable.js
index 0ba1b950db..3e67be7351 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 4c9e07a4cb..ef1492e36c 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 b/test/built-ins/Object/fromEntries/iterator-closed-for-null-entry.js
index b84d87feac..6907a65cad 100644
--- a/test/built-ins/Object/fromEntries/iterator-closed-for-null-entry.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 b/test/built-ins/Object/fromEntries/iterator-closed-for-string-entry.js
index b0c5bc9f90..81a27e0731 100644
--- a/test/built-ins/Object/fromEntries/iterator-closed-for-string-entry.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 9e7f9e4a2c..e042da46da 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 5a845b5b20..a7ccfae51e 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 0000000000..b75139a094
--- /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 8f18c974f0..fba4fbe67e 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 5fd69c116f..f0d2c0833e 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 b5ebcdf3f1..cbb2afaa91 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 f9aa9d23e1..74ad7a739c 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 56615b4d7b..f47c7ba189 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 aa39c2277d..c39ea09568 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 b65051b003..19b91a5307 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 92663304ba..31f0f388d7 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 0000000000..a29e508b65
--- /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');
-- 
GitLab