Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/DataView/negative-byteoffset-throws-sab.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // Copyright (C) 2017 Mozilla Corporation. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-dataview-buffer-byteoffset-bytelength
7 description: >
8 Throws a RangeError if ToInteger(byteOffset) < 0
9 info: |
10 24.2.2.1 DataView (buffer, byteOffset, byteLength )
11
12 ...
13 4. Let offset be ? ToIndex(byteOffset).
14 ...
15
16 ToIndex ( value )
17
18 1. If value is undefined, then
19 a. Let index be 0.
20 2. Else,
21 a. Let integerIndex be ? ToInteger(value).
22 b. If integerIndex < 0, throw a RangeError exception.
23 ...
24 features: [SharedArrayBuffer]
25 ---*/
26
27 var buffer = new SharedArrayBuffer(2);
28
29 assert.throws(RangeError, function() {
30 new DataView(buffer, -1);
31 }, "new DataView(buffer, -1);");
32
33 assert.throws(RangeError, function() {
34 new DataView(buffer, -Infinity);
35 }, "new DataView(buffer, -Infinity);");