blob: b5839b7f92cb71c55cd6e17810bb86039238fe1c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright (c) 2023 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object.groupby
description: Object.groupBy with a nullish Symbol.iterator throws
info: |
Object.groupBy ( items, callbackfn )
...
GroupBy ( items, callbackfn, coercion )
4. Let iteratorRecord be ? GetIterator(items).
...
features: [array-grouping]
---*/
const throws = function () {
throw new Test262Error('callback function should not be called')
};
function makeIterable(obj, iteratorFn) {
obj[Symbol.iterator] = iteratorFn;
return obj;
}
assert.throws(TypeError, function () {
Object.groupBy(makeIterable({}, undefined), throws);
}, 'undefined Symbol.iterator');
assert.throws(TypeError, function () {
Object.groupBy(makeIterable({}, null), throws);
}, 'null Symbol.iterator');
reportCompare(0, 0);
|