Debian Codegraph @

js/src/tests/test262/built-ins/ArrayBuffer/length-is-too-large-throws.js

raw
1 // Copyright (C) 2015 André Bargull. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-arraybuffer-length
6 description: >
7 Throws a RangeError if length >= 2 ** 53
8 info: |
9 ArrayBuffer( length )
10
11 1. If NewTarget is undefined, throw a TypeError exception.
12 2. Let byteLength be ? ToIndex(length).
13
14 ToIndex( value )
15
16 1. If value is undefined, then
17 a. Let index be 0.
18 2. Else,
19 a. Let integerIndex be ? ToInteger(value).
20 b. If integerIndex < 0, throw a RangeError exception.
21 ...
22 ---*/
23
24 assert.throws(RangeError, function() {
25 // Math.pow(2, 53) = 9007199254740992
26 new ArrayBuffer(9007199254740992);
27 }, "`length` parameter is too large");
28
29 assert.throws(RangeError, function() {
30 new ArrayBuffer(Infinity);
31 }, "`length` parameter is positive Infinity");
32
33 reportCompare(0, 0);