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

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`);
}