blob: abbff59a6f8f18d7604a3ed0ab13d98257c3ff6c (
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
|
// |jit-test| --ion-warmup-threshold=50
var PossiblyWrappedArrayBufferByteLength = getSelfHostedValue("PossiblyWrappedArrayBufferByteLength");
function testBasic() {
var arr = [1, 2, 3];
var tarr = new Int32Array(arr);
var abuf = tarr.buffer;
var arrLength = arr.length;
var bytesPerElement = Int32Array.BYTES_PER_ELEMENT;
var f = function() {
assertEq(PossiblyWrappedArrayBufferByteLength(abuf), arrLength * bytesPerElement);
};
do {
f();
} while (!inIon());
}
testBasic();
function testWrapped() {
var g = newGlobal();
g.eval(`
var arr = [1, 2, 3];
var tarr = new Int32Array(arr);
var abuf = tarr.buffer;
`);
var abuf = g.abuf;
var arrLength = g.arr.length;
var bytesPerElement = g.Int32Array.BYTES_PER_ELEMENT;
var f = function() {
assertEq(PossiblyWrappedArrayBufferByteLength(abuf), arrLength * bytesPerElement);
};
do {
f();
} while (!inIon());
}
testWrapped();
|