summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/wasm/function-references/as-non-null.js
blob: 6fd02d61acf26af2a42a5b9e1d6e34ce1cfe91a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
// |jit-test| skip-if: !wasmGcEnabled()

let {checkNonNull} = wasmEvalText(`(module
  (func (export "checkNonNull") (param externref) (result (ref extern))
    local.get 0
    ref.as_non_null
  )
)`).exports;

assertErrorMessage(() => checkNonNull(null), WebAssembly.RuntimeError, /dereferencing null pointer/);
for (let val of WasmNonNullExternrefValues) {
  assertEq(checkNonNull(val), val, `is non-null`);
}