summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/ctypes/size-overflow-struct.js
blob: a40f925a759667d63e0e93a87dedbda5880248aa (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
load(libdir + 'asserts.js');

function test() {
  if (getBuildConfiguration()["pointer-byte-size"] == 4) {
    let big_array = ctypes.int32_t.array(0xfffffff);
    assertRangeErrorMessage(() => { ctypes.StructType("x", [{a: big_array},
                                                            {b: big_array},
                                                            {c: big_array},
                                                            {d: big_array},
                                                            {e: big_array}]); },
                            "struct size does not fit in size_t");
  } else if (getBuildConfiguration()["pointer-byte-size"] == 8) {
    let big_array = ctypes.int32_t.array(0xfffffffffffffff);
    assertRangeErrorMessage(() => { ctypes.StructType("x", [{a: big_array},
                                                            {b: big_array},
                                                            {c: big_array},
                                                            {d: big_array},
                                                            {e: big_array}]); },
                            "struct size does not fit in size_t");
  }
}

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