Add test for length conversion

This commit is contained in:
Justin Ridgewell 2022-09-13 21:30:37 -04:00 committed by Philip Chimento
parent 22fe1b44b2
commit 6cdb375d8c
2 changed files with 37 additions and 1 deletions

View File

@ -15,7 +15,7 @@ info: |
features: [array-grouping]
---*/
const throws = () => {
const throws = function() {
throw new Test262Error('callback function should not be called')
};

View File

@ -0,0 +1,36 @@
// Copyright (c) 2021 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype.group
description: Array.prototype.group errors when array-like's length can't be coerced.
info: |
22.1.3.14 Array.prototype.group ( callbackfn [ , thisArg ] )
...
2. Let len be ? LengthOfArrayLike(O).
...
features: [array-grouping]
---*/
assert.throws(Test262Error, function() {
const arrayLike = Object.defineProperty({}, 'length', {
get: function() {
throw new Test262Error('no length for you');
}
});
Array.prototype.group.call(arrayLike, function() {
return 'key';
});
});
assert.throws(TypeError, function() {
const arrayLike = {
length: 1n,
};
Array.prototype.group.call(arrayLike, function() {
return 'key';
});
});