summaryrefslogtreecommitdiffstats
path: root/js/src/tests/ecma_7/SIMD/load-sab-buffer-compat.js
blob: fe8fac3ede9548a868c79a1ec50fcaa98b26b979 (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
// |reftest| skip-if(!this.hasOwnProperty("SIMD"))

/*
 * Any copyright is dedicated to the Public Domain.
 * https://creativecommons.org/publicdomain/zero/1.0/
 */

var { MakeComparator } = Helpers;

function testSharedArrayBufferCompat() {
    var TA = new Float32Array(new SharedArrayBuffer(16*4));
    for (var i = 0; i < 16; i++)
        TA[i] = i + 1;

    for (var ta of [
                    new Uint8Array(TA.buffer),
                    new Int8Array(TA.buffer),
                    new Uint16Array(TA.buffer),
                    new Int16Array(TA.buffer),
                    new Uint32Array(TA.buffer),
                    new Int32Array(TA.buffer),
                    new Float32Array(TA.buffer),
                    new Float64Array(TA.buffer)
                   ])
    {
        for (var kind of ['Int32x4', 'Uint32x4', 'Float32x4', 'Float64x2']) {
            var comp = MakeComparator(kind, ta);
            comp.load(0);
            comp.load1(0);
            comp.load2(0);
            comp.load3(0);

            comp.load(3);
            comp.load1(3);
            comp.load2(3);
            comp.load3(3);
        }

        assertThrowsInstanceOf(() => SIMD.Int32x4.load(ta, 1024), RangeError);
        assertThrowsInstanceOf(() => SIMD.Uint32x4.load(ta, 1024), RangeError);
        assertThrowsInstanceOf(() => SIMD.Float32x4.load(ta, 1024), RangeError);
        assertThrowsInstanceOf(() => SIMD.Float64x2.load(ta, 1024), RangeError);
    }
}

testSharedArrayBufferCompat();

if (typeof reportCompare === "function")
    reportCompare(true, true);