diff options
author | Casper Beyer <caspervonb@pm.me> | 2020-12-10 20:37:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-10 13:37:09 +0100 |
commit | 77b2bc3bc1c986d8fce90a144bdfdb66a7537efe (patch) | |
tree | b5a49b8db610e5708cde73b79c9c9bb6004b195f /std/wasi/snapshot_preview1_test.ts | |
parent | c5ccbf3699ebe2d9548a89d6e7ef70636fae0cd4 (diff) |
fix(std/wasi): disallow multiple starts (#8712)
Diffstat (limited to 'std/wasi/snapshot_preview1_test.ts')
-rw-r--r-- | std/wasi/snapshot_preview1_test.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/std/wasi/snapshot_preview1_test.ts b/std/wasi/snapshot_preview1_test.ts index f102f083d..55982545f 100644 --- a/std/wasi/snapshot_preview1_test.ts +++ b/std/wasi/snapshot_preview1_test.ts @@ -198,6 +198,23 @@ Deno.test("context_start", function () { assert(err instanceof ExitStatus); assertEquals(err.code, 0); } + + assertThrows( + () => { + const context = new Context({}); + context.start({ + exports: { + memory: new WebAssembly.Memory({ initial: 1 }), + _start() {}, + }, + }); + context.start({ + exports: {}, + }); + }, + Error, + "WebAssembly.Instance has already started", + ); }); Deno.test("context_initialize", function () { @@ -240,4 +257,20 @@ Deno.test("context_initialize", function () { TypeError, "export _initialize must be a function", ); + assertThrows( + () => { + const context = new Context({}); + context.initialize({ + exports: { + memory: new WebAssembly.Memory({ initial: 1 }), + _initialize() {}, + }, + }); + context.initialize({ + exports: {}, + }); + }, + Error, + "WebAssembly.Instance has already started", + ); }); |