summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ctypes/size-overflow-array.js
blob: 8b51faec52673c44411169269ac76c0534999391 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
load(libdir + 'asserts.js');

function test() {
  if (getBuildConfiguration("pointer-byte-size") == 4) {
    let big_array = ctypes.int32_t.array(0xfffffff);
    assertRangeErrorMessage(() => { big_array.array(0xfffffff); },
                            "array size does not fit in size_t");
  } else if (getBuildConfiguration("pointer-byte-size") == 8) {
    let big_array = ctypes.int32_t.array(0xfffffff);
    assertRangeErrorMessage(() => { big_array.array(0xfffffff); },
                            "array size does not fit in JavaScript number");
    assertRangeErrorMessage(() => { big_array.array(0xfffffffff); },
                            "array size does not fit in size_t");
  }
}

if (typeof ctypes === "object")
  test();