Debian Codegraph @

js/src/tests/test262/built-ins/Array/length/define-own-prop-length-error.js

raw
1 // Copyright (C) 2023 Jordan Harband. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 author: Jordan Harband
6 esid: sec-arraysetlength
7 description: >
8 Setting an invalid array length throws a RangeError
9 info: |
10 ArraySetLength ( A, Desc )
11
12 [...]
13 5. If SameValueZero(newLen, numberLen) is false, throw a RangeError exception.
14 [...]
15 ---*/
16
17 assert.throws(RangeError, function () {
18 Object.defineProperty([], 'length', { value: -1, configurable: true });
19 });
20
21 assert.throws(RangeError, function () {
22 // the string is intentionally "computed" here to ensure there are no optimization bugs
23 Object.defineProperty([], 'len' + 'gth', { value: -1, configurable: true });
24 });
25
26 reportCompare(0, 0);