summaryrefslogtreecommitdiff
path: root/test/built-ins/DataView/prototype/getBigUint64/index-is-out-of-range.js
blob: 7f25d2e67755cdfeacf4289ee23ec8ff4715a3c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-dataview.prototype.getbiguint64
description: >
  Throws a RangeError if getIndex + elementSize > viewSize
features: [DataView, ArrayBuffer, BigInt, arrow-function]
---*/

var sample;
var buffer = new ArrayBuffer(12);

sample = new DataView(buffer, 0);

assert.throws(RangeError, () => sample.getBigUint64(Infinity),
  "DataView access at index Infinity should throw");

assert.throws(RangeError, () => sample.getBigUint64(13), "13 + 8 > 12");

assert.throws(RangeError, () => sample.getBigUint64(12), "12 + 8 > 12");

assert.throws(RangeError, () => sample.getBigUint64(11), "11 + 8 > 12");

assert.throws(RangeError, () => sample.getBigUint64(10), "10 + 8 > 12");

assert.throws(RangeError, () => sample.getBigUint64(9), "9 + 8 > 12");

assert.throws(RangeError, () => sample.getBigUint64(8), "8 + 8 > 12");

assert.throws(RangeError, () => sample.getBigUint64(7), "7 + 8 > 12");

assert.throws(RangeError, () => sample.getBigUint64(6), "6 + 8 > 12");

assert.throws(RangeError, () => sample.getBigUint64(5), "5 + 8 > 12");

sample = new DataView(buffer, 8);
assert.throws(RangeError, () => sample.getBigUint64(1),
  "1 + 8 > 4 (offset)");

sample = new DataView(buffer, 9);
assert.throws(RangeError, () => sample.getBigUint64(0),
  "0 + 8 > 3 (offset)");

sample = new DataView(buffer, 0, 8);
assert.throws(RangeError, () => sample.getBigUint64(1),
  "1 + 8 > 8 (length)");

sample = new DataView(buffer, 0, 7);
assert.throws(RangeError, () => sample.getBigUint64(0),
  "0 + 8 > 7 (length)");

sample = new DataView(buffer, 4, 8);
assert.throws(RangeError, () => sample.getBigUint64(1),
  "1 + 8 > 8 (offset+length)");

sample = new DataView(buffer, 4, 7);
assert.throws(RangeError, () => sample.getBigUint64(0),
  "0 + 8 > 7 (offset+length)");