| import * as assert from '../assert.js'; |
| |
| function module(bytes, valid = true) { |
| let buffer = new ArrayBuffer(bytes.length); |
| let view = new Uint8Array(buffer); |
| for (let i = 0; i < bytes.length; ++i) { |
| view[i] = bytes.charCodeAt(i); |
| } |
| return new WebAssembly.Module(buffer); |
| } |
| |
| async function blockSignatureTest() { |
| /* |
| (module |
| (type (func)) |
| (func (type 0)) |
| (elem declare funcref (ref.func 0)) |
| (func (result) |
| (block (result (ref 0)) |
| (ref.func 0)) |
| drop) |
| ) |
| */ |
| new WebAssembly.Instance(module("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x84\x80\x80\x80\x00\x01\x60\x00\x00\x03\x83\x80\x80\x80\x00\x02\x00\x00\x09\x87\x80\x80\x80\x00\x01\x07\x70\x01\xd2\x00\x0b\x0a\x96\x80\x80\x80\x00\x02\x82\x80\x80\x80\x00\x00\x0b\x89\x80\x80\x80\x00\x00\x02\x64\x00\xd2\x00\x0b\x1a\x0b")); |
| |
| /* |
| (module |
| (type (func)) |
| (func (result) |
| (block (result (ref null 0)) |
| (ref.null 0)) |
| drop) |
| ) |
| */ |
| new WebAssembly.Instance(module("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x84\x80\x80\x80\x00\x01\x60\x00\x00\x03\x82\x80\x80\x80\x00\x01\x00\x0a\x8f\x80\x80\x80\x00\x01\x89\x80\x80\x80\x00\x00\x02\x63\x00\xd0\x00\x0b\x1a\x0b")); |
| |
| // Both shorthand and Ref encodings tested below. |
| /* |
| (module |
| (func (result) |
| (block (result (ref null extern)) |
| (ref.null extern)) |
| drop) |
| ) |
| */ |
| new WebAssembly.Instance(module("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x84\x80\x80\x80\x00\x01\x60\x00\x00\x03\x82\x80\x80\x80\x00\x01\x00\x0a\x8e\x80\x80\x80\x00\x01\x88\x80\x80\x80\x00\x00\x02\x6f\xd0\x6f\x0b\x1a\x0b")); |
| new WebAssembly.Instance(module("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x84\x80\x80\x80\x00\x01\x60\x00\x00\x03\x82\x80\x80\x80\x00\x01\x00\x0a\x8f\x80\x80\x80\x00\x01\x89\x80\x80\x80\x00\x00\x02\x63\x6f\xd0\x6f\x0b\x1a\x0b")); |
| |
| /* |
| (module |
| (func (result) |
| (block (result (ref null func)) |
| (ref.null func)) |
| drop) |
| ) |
| */ |
| new WebAssembly.Instance(module("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x84\x80\x80\x80\x00\x01\x60\x00\x00\x03\x82\x80\x80\x80\x00\x01\x00\x0a\x8e\x80\x80\x80\x00\x01\x88\x80\x80\x80\x00\x00\x02\x70\xd0\x70\x0b\x1a\x0b")); |
| new WebAssembly.Instance(module("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x84\x80\x80\x80\x00\x01\x60\x00\x00\x03\x82\x80\x80\x80\x00\x01\x00\x0a\x8f\x80\x80\x80\x00\x01\x89\x80\x80\x80\x00\x00\x02\x63\x70\xd0\x70\x0b\x1a\x0b")); |
| } |
| |
| await assert.asyncTest(blockSignatureTest()); |