diff options
Diffstat (limited to 'js/src/jit-test/tests/wasm/gc/anyref.js')
-rw-r--r-- | js/src/jit-test/tests/wasm/gc/anyref.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/wasm/gc/anyref.js b/js/src/jit-test/tests/wasm/gc/anyref.js new file mode 100644 index 0000000000..a15c893a96 --- /dev/null +++ b/js/src/jit-test/tests/wasm/gc/anyref.js @@ -0,0 +1,23 @@ +// |jit-test| skip-if: !wasmGcEnabled() + +// Functions with anyref in results or params cannot be called +assertErrorMessage(() => wasmEvalText(`(module + (func (export "func") (param anyref)) +)`).exports.func(null), TypeError, /cannot pass/); +assertErrorMessage(() => wasmEvalText(`(module + (func (export "func") (result anyref) ref.null any) +)`).exports.func(), TypeError, /cannot pass/); + +// Globals of anyref cannot be accessed +let {global} = wasmEvalText(`(module + (global (export "global") (mut anyref) ref.null any) +)`).exports; +assertErrorMessage(() => global.value, TypeError, /cannot pass/); +assertErrorMessage(() => global.value = null, TypeError, /cannot pass/); + +// Tables of anyref cannot be accessed +let {table} = wasmEvalText(`(module + (table (export "table") anyref (elem (ref.null any))) +)`).exports; +assertErrorMessage(() => table.get(0), TypeError, /cannot pass/); +assertErrorMessage(() => table.set(0, null), TypeError, /cannot pass/); |