blob: 6e827dfca84340bc750df41346b7f5b677ebe025 [file] [log] [blame]
import * as assert from '../assert.js';
import { instantiate } from "../wabt-wrapper.js";
async function test() {
let wat = `
(module
(import "env" "memory" (memory $mem0 1 1))
(func (export "fill_oob")
(memory.fill (i32.const 0) (i32.const 42) (i32.const 65537))
)
)
`;
let memory = new WebAssembly.Memory({initial: 1, maximum: 1});
const instance = await instantiate(wat, {env: {"memory": memory}}, {reference_types: true});
assert.throws(() => { instance.exports.fill_oob() }, WebAssembly.RuntimeError, "Out of bounds memory access");
}
assert.asyncTest(test());