summaryrefslogtreecommitdiffstats
path: root/js/src/tests/non262/TypedArray/large-arrays.js
blob: 5d65c21464aaf2ff9ae82d30c1a8a16640d97c69 (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
// |reftest| shell-option(--enable-float16array) slow skip-if(!xulRuntime.shell)

// Test that we can access TypedArrays beyond the 4GB mark, if large buffers are
// supported.

const gb = 1024 * 1024 * 1024;

if (largeArrayBufferSupported()) {
    for (let TA of typedArrayConstructors) {
        let ta = new TA(6*gb / TA.BYTES_PER_ELEMENT);

        // Set element at the 5GB mark
        ta[5*gb / TA.BYTES_PER_ELEMENT] = 37;

        // Check that it was set
        assertEq(ta[5*gb / TA.BYTES_PER_ELEMENT], 37);

        // Check that we're not operating mod 4GB
        assertEq(ta[1*gb / TA.BYTES_PER_ELEMENT], 0);
    }
}

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