mirror of
https://github.com/tc39/test262.git
synced 2025-07-21 13:04:39 +02:00
Object.fromEntries: use verifyProperty; add specification details
This commit is contained in:
parent
55ffeaf5cf
commit
ff475fce11
@ -2,8 +2,16 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// 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
|
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]
|
features: [Object.fromEntries]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -2,8 +2,16 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// 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
|
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]
|
includes: [compareArray.js]
|
||||||
features: [Symbol.iterator, Object.fromEntries]
|
features: [Symbol.iterator, Object.fromEntries]
|
||||||
---*/
|
---*/
|
||||||
|
@ -2,8 +2,25 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// 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
|
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]
|
features: [Symbol.iterator, Object.fromEntries]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
@ -19,7 +36,7 @@ var iterable = {
|
|||||||
advanced = true;
|
advanced = true;
|
||||||
return {
|
return {
|
||||||
done: false,
|
done: false,
|
||||||
value: 'null',
|
value: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
return: function() {
|
return: function() {
|
||||||
|
@ -2,8 +2,25 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// 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
|
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]
|
features: [Symbol.iterator, Object.fromEntries]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -2,8 +2,24 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// 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
|
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]
|
features: [Symbol.iterator, Object.fromEntries]
|
||||||
---*/
|
---*/
|
||||||
|
|
@ -2,8 +2,24 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// 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
|
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]
|
features: [Symbol.iterator, Object.fromEntries]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -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');
|
@ -2,8 +2,33 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// 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
|
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]
|
features: [Symbol.iterator, Object.fromEntries]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -2,8 +2,33 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// 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
|
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]
|
features: [Symbol.iterator, Object.fromEntries]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -2,8 +2,33 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// 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
|
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]
|
features: [Symbol.iterator, Object.fromEntries]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -2,8 +2,26 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// 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
|
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]
|
features: [Symbol.iterator, Object.fromEntries]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -8,8 +8,9 @@ includes: [propertyHelper.js]
|
|||||||
features: [Object.fromEntries]
|
features: [Object.fromEntries]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(Object.fromEntries.length, 1);
|
verifyProperty(Object.fromEntries, "length", {
|
||||||
|
value: 1,
|
||||||
verifyNotEnumerable(Object.fromEntries, "length");
|
enumerable: false,
|
||||||
verifyNotWritable(Object.fromEntries, "length");
|
writable: false,
|
||||||
verifyConfigurable(Object.fromEntries, "length");
|
configurable: true
|
||||||
|
});
|
||||||
|
@ -8,8 +8,9 @@ includes: [propertyHelper.js]
|
|||||||
features: [Object.fromEntries]
|
features: [Object.fromEntries]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.sameValue(Object.fromEntries.name, "fromEntries");
|
verifyProperty(Object.fromEntries, "name", {
|
||||||
|
value: "fromEntries",
|
||||||
verifyNotEnumerable(Object.fromEntries, "name");
|
enumerable: false,
|
||||||
verifyNotWritable(Object.fromEntries, "name");
|
writable: false,
|
||||||
verifyConfigurable(Object.fromEntries, "name");
|
configurable: true
|
||||||
|
});
|
||||||
|
@ -2,8 +2,15 @@
|
|||||||
// This code is governed by the BSD license found in the LICENSE file.
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
/*---
|
/*---
|
||||||
description: Throws when called without an argument.
|
|
||||||
esid: sec-object.fromentries
|
esid: sec-object.fromentries
|
||||||
|
description: Throws when called without an argument.
|
||||||
|
info: |
|
||||||
|
|
||||||
|
Object.fromEntries ( iterable )
|
||||||
|
|
||||||
|
1. Perform ? RequireObjectCoercible(iterable).
|
||||||
|
...
|
||||||
|
|
||||||
features: [Object.fromEntries]
|
features: [Object.fromEntries]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ features: [Object.fromEntries]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
var result = Object.fromEntries([['key', 'value']]);
|
var result = Object.fromEntries([['key', 'value']]);
|
||||||
verifyEnumerable(result, 'key');
|
verifyProperty(result, "key", {
|
||||||
verifyWritable(result, 'key');
|
enumerable: true,
|
||||||
verifyConfigurable(result, 'key');
|
writable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
@ -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');
|
Loading…
x
Reference in New Issue
Block a user