summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ctypes/size-overflow-array.js
blob: 290046a6e86f4a0705d7483e4ab11226ddba4a6c (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();