summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/testTypedArrayUndefinedAndHoles.js
blob: 0800b108594d22b54209c7422931d0612fa7c7a3 (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
function holeArray(sparse) {
    var a = [,,];
    if (sparse)
        a.length = 1000;
    return a;
}

function undefinedArray(sparse) {
    var a = [ undefined, undefined, undefined ];
    if (sparse)
        a.length = 1000;
    return a;
}

var a;
a = new Int32Array(holeArray(false));
assertEq(a[0], 0);
a = new Int32Array(holeArray(true));
assertEq(a[0], 0);
a = new Int32Array(undefinedArray(false));
assertEq(a[0], 0);
a = new Int32Array(undefinedArray(true));
assertEq(a[0], 0);

a = new Float64Array(holeArray(false));
assertEq(a[0], NaN);
a = new Float64Array(holeArray(true));
assertEq(a[0], NaN);
a = new Float64Array(undefinedArray(false));
assertEq(a[0], NaN);
a = new Float64Array(undefinedArray(true));
assertEq(a[0], NaN);