summaryrefslogtreecommitdiff
path: root/test/built-ins/DataView/prototype/getBigInt64/toindex-byteoffset-wrapped-values.js
blob: b0baccc944d32011a7afa979b646bb7a7d127b70 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// 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.getbigint64
info: |
  DataView.prototype.getBigInt64 ( byteOffset [ , littleEndian ] )

  1. Let v be the this value.
  2. If littleEndian is not present, let littleEndian be undefined.
  3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int64").

  24.3.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )

  ...
  4. Let getIndex be ? ToIndex(requestIndex).
  ...
features: [ArrayBuffer, BigInt, DataView, DataView.prototype.setUint8, 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.sameValue(sample.getBigInt64(Object(0)), 0x2702060280008001 n,
  "ToPrimitive: unbox object with internal slot");
assert.sameValue(sample.getBigInt64({
  [Symbol.toPrimitive]: function() {
    return 0;
  }
}), 0x2702060280008001 n, "ToPrimitive: @@toPrimitive");
assert.sameValue(sample.getBigInt64({
  valueOf: function() {
    return 0;
  }
}), 0x2702060280008001 n, "ToPrimitive: valueOf");
assert.sameValue(sample.getBigInt64({
  toString: function() {
    return 0;
  }
}), 0x2702060280008001 n, "ToPrimitive: toString");
assert.sameValue(sample.getBigInt64(Object(NaN)), 0x2702060280008001 n,
  "ToIndex: unbox object with internal slot => NaN => 0");
assert.sameValue(sample.getBigInt64({
  [Symbol.toPrimitive]: function() {
    return NaN;
  }
}), 0x2702060280008001 n, "ToIndex: @@toPrimitive => NaN => 0");
assert.sameValue(sample.getBigInt64({
  valueOf: function() {
    return NaN;
  }
}), 0x2702060280008001 n, "ToIndex: valueOf => NaN => 0");
assert.sameValue(sample.getBigInt64({
  toString: function() {
    return NaN;
  }
}), 0x2702060280008001 n, "ToIndex: toString => NaN => 0");
assert.sameValue(sample.getBigInt64({
  [Symbol.toPrimitive]: function() {
    return undefined;
  }
}), 0x2702060280008001 n, "ToIndex: @@toPrimitive => undefined => NaN => 0");
assert.sameValue(sample.getBigInt64({
  valueOf: function() {
    return undefined;
  }
}), 0x2702060280008001 n, "ToIndex: valueOf => undefined => NaN => 0");
assert.sameValue(sample.getBigInt64({
  toString: function() {
    return undefined;
  }
}), 0x2702060280008001 n, "ToIndex: toString => undefined => NaN => 0");
assert.sameValue(sample.getBigInt64({
  [Symbol.toPrimitive]: function() {
    return null;
  }
}), 0x2702060280008001 n, "ToIndex: @@toPrimitive => null => 0");
assert.sameValue(sample.getBigInt64({
  valueOf: function() {
    return null;
  }
}), 0x2702060280008001 n, "ToIndex: valueOf => null => 0");
assert.sameValue(sample.getBigInt64({
  toString: function() {
    return null;
  }
}), 0x2702060280008001 n, "ToIndex: toString => null => 0");
assert.sameValue(sample.getBigInt64(Object(true)), 0x20602800080017f n,
  "ToIndex: unbox object with internal slot => true => 1");
assert.sameValue(sample.getBigInt64({
  [Symbol.toPrimitive]: function() {
    return true;
  }
}), 0x20602800080017f n, "ToIndex: @@toPrimitive => true => 1");
assert.sameValue(sample.getBigInt64({
  valueOf: function() {
    return true;
  }
}), 0x20602800080017f n, "ToIndex: valueOf => true => 1");
assert.sameValue(sample.getBigInt64({
  toString: function() {
    return true;
  }
}), 0x20602800080017f n, "ToIndex: toString => true => 1");
assert.sameValue(sample.getBigInt64(Object("1")), 0x20602800080017f n,
  "ToIndex: unbox object with internal slot => parse Number");
assert.sameValue(sample.getBigInt64({
  [Symbol.toPrimitive]: function() {
    return "1";
  }
}), 0x20602800080017f n, "ToIndex: @@toPrimitive => parse Number");
assert.sameValue(sample.getBigInt64({
  valueOf: function() {
    return "1";
  }
}), 0x20602800080017f n, "ToIndex: valueOf => parse Number");
assert.sameValue(sample.getBigInt64({
  toString: function() {
    return "1";
  }
}), 0x20602800080017f n, "ToIndex: toString => parse Number");