summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/DataView/prototype/getBigUint64/toindex-byteoffset-errors.js
blob: 3727b63af7e3da8e240217c2fca27bd3cb0daf8e (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright (C) 2017 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: ToIndex conversions on byteOffset
esid: sec-dataview.prototype.getbiguint64
features: [ArrayBuffer, BigInt, DataView, DataView.prototype.setUint8, Symbol, Symbol.toPrimitive, computed-property-names]
---*/

var buffer = new ArrayBuffer(12);
var sample = new DataView(buffer, 0);
sample.setUint8(0, 0x27);
sample.setUint8(1, 0x02);
sample.setUint8(2, 0x06);
sample.setUint8(3, 0x02);
sample.setUint8(4, 0x80);
sample.setUint8(5, 0x00);
sample.setUint8(6, 0x80);
sample.setUint8(7, 0x01);
sample.setUint8(8, 0x7f);
sample.setUint8(9, 0x00);
sample.setUint8(10, 0x01);
sample.setUint8(11, 0x02);

assert.throws(RangeError, function() {
  sample.getBigUint64(-1);
}, "ToIndex: throw when integerIndex < 0");
assert.throws(RangeError, function() {
  sample.getBigUint64(-2.5);
}, "ToIndex: throw when integerIndex < 0");
assert.throws(RangeError, function() {
  sample.getBigUint64("-2.5");
}, "ToIndex: parse Number => throw when integerIndex < 0");
assert.throws(RangeError, function() {
  sample.getBigUint64(-Infinity);
}, "ToIndex: throw when integerIndex < 0");
assert.throws(RangeError, function() {
  sample.getBigUint64(9007199254740992);
}, "ToIndex: throw when integerIndex > 2**53-1");
assert.throws(RangeError, function() {
  sample.getBigUint64(Infinity);
}, "ToIndex: throw when integerIndex > 2**53-1");
assert.throws(TypeError, function() {
  sample.getBigUint64(0n);
}, "ToIndex: BigInt => TypeError");
assert.throws(TypeError, function() {
  sample.getBigUint64(Object(0n));
}, "ToIndex: unbox object with internal slot => BigInt => TypeError");
assert.throws(TypeError, function() {
  sample.getBigUint64({
    [Symbol.toPrimitive]: function() {
      return 0n;
    }
  });
}, "ToIndex: @@toPrimitive => BigInt => TypeError");
assert.throws(TypeError, function() {
  sample.getBigUint64({
    valueOf: function() {
      return 0n;
    }
  });
}, "ToIndex: valueOf => BigInt => TypeError");
assert.throws(TypeError, function() {
  sample.getBigUint64({
    toString: function() {
      return 0n;
    }
  });
}, "ToIndex: toString => BigInt => TypeError");
assert.throws(TypeError, function() {
  sample.getBigUint64(Symbol("1"));
}, "ToIndex: Symbol => TypeError");
assert.throws(TypeError, function() {
  sample.getBigUint64(Object(Symbol("1")));
}, "ToIndex: unbox object with internal slot => Symbol => TypeError");
assert.throws(TypeError, function() {
  sample.getBigUint64({
    [Symbol.toPrimitive]: function() {
      return Symbol("1");
    }
  });
}, "ToIndex: @@toPrimitive => Symbol => TypeError");
assert.throws(TypeError, function() {
  sample.getBigUint64({
    valueOf: function() {
      return Symbol("1");
    }
  });
}, "ToIndex: valueOf => Symbol => TypeError");
assert.throws(TypeError, function() {
  sample.getBigUint64({
    toString: function() {
      return Symbol("1");
    }
  });
}, "ToIndex: toString => Symbol => TypeError");

reportCompare(0, 0);