summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Object/groupBy/invalid-iterable.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Object/groupBy/invalid-iterable.js')
-rw-r--r--js/src/tests/test262/built-ins/Object/groupBy/invalid-iterable.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Object/groupBy/invalid-iterable.js b/js/src/tests/test262/built-ins/Object/groupBy/invalid-iterable.js
new file mode 100644
index 0000000000..b5839b7f92
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/groupBy/invalid-iterable.js
@@ -0,0 +1,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);