invalid-property-key.js (795B)
1 // Copyright (c) 2023 Ecma International. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-object.groupby 6 description: Object.groupBy errors when callback return value cannot be converted to a property key. 7 info: | 8 Object.groupBy ( items, callbackfn ) 9 10 ... 11 GroupBy ( items, callbackfn, coercion ) 12 13 6. Repeat, 14 g. If coercion is property, then 15 i. Set key to Completion(ToPropertyKey(key)). 16 ii. IfAbruptCloseIterator(key, iteratorRecord). 17 18 ... 19 features: [array-grouping] 20 ---*/ 21 22 assert.throws(Test262Error, function () { 23 const array = [1]; 24 Object.groupBy(array, function () { 25 return { 26 toString() { 27 throw new Test262Error('not a property key'); 28 } 29 }; 30 }) 31 }); 32 33 reportCompare(0, 0);