| /* Lovingly generated by gen-spec-js.py based on the wonderful content of * |
| * https://github.com/WebAssembly/spec/blob/master/interpreter/host/js.ml */ |
| 'use strict'; |
| |
| let soft_validate = true; |
| |
| let spectest = { |
| print: print || ((...xs) => console.log(...xs)), |
| global: 666, |
| table: new WebAssembly.Table({initial: 10, maximum: 20, element: 'anyfunc'}), |
| memory: new WebAssembly.Memory({initial: 1, maximum: 2}),}; |
| |
| let registry = {spectest}; |
| let $$; |
| |
| function register(name, instance) { |
| registry[name] = instance.exports; |
| } |
| |
| function module(bytes) { |
| 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); |
| } |
| |
| function instance(bytes, imports = registry) { |
| return new WebAssembly.Instance(module(bytes), imports); |
| } |
| |
| function assert_malformed(bytes) { |
| try { module(bytes) } catch (e) { |
| if (e instanceof WebAssembly.CompileError) return; |
| } |
| throw new Error("Wasm decoding failure expected"); |
| } |
| |
| function assert_invalid(bytes) { |
| try { module(bytes) } catch (e) { |
| if (e instanceof WebAssembly.CompileError) return; |
| } |
| throw new Error("Wasm validation failure expected"); |
| } |
| |
| function assert_soft_invalid(bytes) { |
| try { module(bytes) } catch (e) { |
| if (e instanceof WebAssembly.CompileError) return; |
| throw new Error("Wasm validation failure expected"); |
| } |
| if (soft_validate) |
| throw new Error("Wasm validation failure expected"); |
| } |
| |
| function assert_unlinkable(bytes) { |
| let mod = module(bytes); |
| try { new WebAssembly.Instance(mod, registry) } catch (e) { |
| if (e instanceof TypeError) return; |
| } |
| throw new Error("Wasm linking failure expected"); |
| } |
| |
| function assert_uninstantiable(bytes) { |
| let mod = module(bytes); |
| try { new WebAssembly.Instance(mod, registry) } catch (e) { |
| if (e instanceof WebAssembly.RuntimeError) return; |
| } |
| throw new Error("Wasm trap expected"); |
| } |
| |
| function assert_trap(action) { |
| try { action() } catch (e) { |
| if (e instanceof WebAssembly.RuntimeError) return; |
| } |
| throw new Error("Wasm trap expected"); |
| } |
| |
| function assert_return(action, expected) { |
| let actual = action(); |
| if (!Object.is(actual, expected)) { |
| throw new Error("Wasm return value " + expected + " expected, got " + actual); |
| }; |
| } |
| |
| function assert_return_nan(action) { |
| let actual = action(); |
| if (!Number.isNaN(actual)) { |
| throw new Error("Wasm return value NaN expected, got " + actual); |
| }; |
| } |
| |
| let f32 = Math.fround; |
| |
| $$ = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x27\x08\x60\x02\x7f\x7f\x00\x60\x02\x7f\x7e\x00\x60\x01\x7f\x01\x7f\x60\x01\x7f\x01\x7e\x60\x01\x7e\x01\x7e\x60\x01\x7d\x01\x7d\x60\x01\x7c\x01\x7c\x60\x00\x00\x03\x38\x37\x00\x00\x01\x02\x02\x03\x02\x02\x02\x04\x04\x04\x04\x04\x05\x06\x02\x02\x04\x04\x04\x05\x06\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x07\x05\x03\x01\x00\x01\x07\xd7\x04\x31\x0c\x69\x33\x32\x5f\x6c\x6f\x61\x64\x31\x36\x5f\x73\x00\x06\x0c\x69\x33\x32\x5f\x6c\x6f\x61\x64\x31\x36\x5f\x75\x00\x07\x08\x69\x33\x32\x5f\x6c\x6f\x61\x64\x00\x08\x0c\x69\x36\x34\x5f\x6c\x6f\x61\x64\x31\x36\x5f\x73\x00\x09\x0c\x69\x36\x34\x5f\x6c\x6f\x61\x64\x31\x36\x5f\x75\x00\x0a\x0c\x69\x36\x34\x5f\x6c\x6f\x61\x64\x33\x32\x5f\x73\x00\x0b\x0c\x69\x36\x34\x5f\x6c\x6f\x61\x64\x33\x32\x5f\x75\x00\x0c\x08\x69\x36\x34\x5f\x6c\x6f\x61\x64\x00\x0d\x08\x66\x33\x32\x5f\x6c\x6f\x61\x64\x00\x0e\x08\x66\x36\x34\x5f\x6c\x6f\x61\x64\x00\x0f\x0b\x69\x33\x32\x5f\x73\x74\x6f\x72\x65\x31\x36\x00\x10\x09\x69\x33\x32\x5f\x73\x74\x6f\x72\x65\x00\x11\x0b\x69\x36\x34\x5f\x73\x74\x6f\x72\x65\x31\x36\x00\x12\x0b\x69\x36\x34\x5f\x73\x74\x6f\x72\x65\x33\x32\x00\x13\x09\x69\x36\x34\x5f\x73\x74\x6f\x72\x65\x00\x14\x09\x66\x33\x32\x5f\x73\x74\x6f\x72\x65\x00\x15\x09\x66\x36\x34\x5f\x73\x74\x6f\x72\x65\x00\x16\x08\x61\x73\x73\x65\x72\x74\x5f\x30\x00\x17\x08\x61\x73\x73\x65\x72\x74\x5f\x31\x00\x18\x08\x61\x73\x73\x65\x72\x74\x5f\x32\x00\x19\x08\x61\x73\x73\x65\x72\x74\x5f\x33\x00\x1a\x08\x61\x73\x73\x65\x72\x74\x5f\x34\x00\x1b\x08\x61\x73\x73\x65\x72\x74\x5f\x35\x00\x1c\x08\x61\x73\x73\x65\x72\x74\x5f\x36\x00\x1d\x08\x61\x73\x73\x65\x72\x74\x5f\x37\x00\x1e\x08\x61\x73\x73\x65\x72\x74\x5f\x38\x00\x1f\x08\x61\x73\x73\x65\x72\x74\x5f\x39\x00\x20\x09\x61\x73\x73\x65\x72\x74\x5f\x31\x30\x00\x21\x09\x61\x73\x73\x65\x72\x74\x5f\x31\x31\x00\x22\x09\x61\x73\x73\x65\x72\x74\x5f\x31\x32\x00\x23\x09\x61\x73\x73\x65\x72\x74\x5f\x31\x33\x00\x24\x09\x61\x73\x73\x65\x72\x74\x5f\x31\x34\x00\x25\x09\x61\x73\x73\x65\x72\x74\x5f\x31\x35\x00\x26\x09\x61\x73\x73\x65\x72\x74\x5f\x31\x36\x00\x27\x09\x61\x73\x73\x65\x72\x74\x5f\x31\x37\x00\x28\x09\x61\x73\x73\x65\x72\x74\x5f\x31\x38\x00\x29\x09\x61\x73\x73\x65\x72\x74\x5f\x31\x39\x00\x2a\x09\x61\x73\x73\x65\x72\x74\x5f\x32\x30\x00\x2b\x09\x61\x73\x73\x65\x72\x74\x5f\x32\x31\x00\x2c\x09\x61\x73\x73\x65\x72\x74\x5f\x32\x32\x00\x2d\x09\x61\x73\x73\x65\x72\x74\x5f\x32\x33\x00\x2e\x09\x61\x73\x73\x65\x72\x74\x5f\x32\x34\x00\x2f\x09\x61\x73\x73\x65\x72\x74\x5f\x32\x35\x00\x30\x09\x61\x73\x73\x65\x72\x74\x5f\x32\x36\x00\x31\x09\x61\x73\x73\x65\x72\x74\x5f\x32\x37\x00\x32\x09\x61\x73\x73\x65\x72\x74\x5f\x32\x38\x00\x33\x09\x61\x73\x73\x65\x72\x74\x5f\x32\x39\x00\x34\x09\x61\x73\x73\x65\x72\x74\x5f\x33\x30\x00\x35\x09\x61\x73\x73\x65\x72\x74\x5f\x33\x31\x00\x36\x0a\xd2\x08\x37\x16\x00\x20\x00\x20\x01\x3a\x00\x00\x20\x00\x41\x01\x6a\x20\x01\x41\x08\x76\x3a\x00\x00\x0b\x14\x00\x20\x00\x20\x01\x10\x00\x20\x00\x41\x02\x6a\x20\x01\x41\x10\x76\x10\x00\x0b\x16\x00\x20\x00\x20\x01\xa7\x10\x01\x20\x00\x41\x04\x6a\x20\x01\x42\x20\x88\xa7\x10\x01\x0b\x13\x00\x20\x00\x2d\x00\x00\x20\x00\x41\x01\x6a\x2d\x00\x00\x41\x08\x74\x72\x0b\x11\x00\x20\x00\x10\x03\x20\x00\x41\x02\x6a\x10\x03\x41\x10\x74\x72\x0b\x13\x00\x20\x00\x10\x04\xad\x20\x00\x41\x04\x6a\x10\x04\xad\x42\x20\x86\x84\x0b\x0d\x00\x41\x00\x20\x00\x10\x00\x41\x00\x2e\x01\x00\x0b\x0d\x00\x41\x00\x20\x00\x10\x00\x41\x00\x2f\x01\x00\x0b\x0d\x00\x41\x00\x20\x00\x10\x01\x41\x00\x28\x02\x00\x0b\x0e\x00\x41\x00\x20\x00\xa7\x10\x00\x41\x00\x32\x01\x00\x0b\x0e\x00\x41\x00\x20\x00\xa7\x10\x00\x41\x00\x33\x01\x00\x0b\x0e\x00\x41\x00\x20\x00\xa7\x10\x01\x41\x00\x34\x02\x00\x0b\x0e\x00\x41\x00\x20\x00\xa7\x10\x01\x41\x00\x35\x02\x00\x0b\x0d\x00\x41\x00\x20\x00\x10\x02\x41\x00\x29\x03\x00\x0b\x0e\x00\x41\x00\x20\x00\xbc\x10\x01\x41\x00\x2a\x02\x00\x0b\x0e\x00\x41\x00\x20\x00\xbd\x10\x02\x41\x00\x2b\x03\x00\x0b\x0d\x00\x41\x00\x20\x00\x3b\x01\x00\x41\x00\x10\x03\x0b\x0d\x00\x41\x00\x20\x00\x36\x02\x00\x41\x00\x10\x04\x0b\x0e\x00\x41\x00\x20\x00\x3d\x01\x00\x41\x00\x10\x03\xad\x0b\x0e\x00\x41\x00\x20\x00\x3e\x02\x00\x41\x00\x10\x04\xad\x0b\x0d\x00\x41\x00\x20\x00\x37\x03\x00\x41\x00\x10\x05\x0b\x0e\x00\x41\x00\x20\x00\x38\x02\x00\x41\x00\x10\x04\xbe\x0b\x0e\x00\x41\x00\x20\x00\x39\x03\x00\x41\x00\x10\x05\xbf\x0b\x11\x00\x02\x40\x42\x7f\x10\x09\x42\x7f\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x13\x00\x02\x40\x42\xee\x5e\x10\x09\x42\xee\x5e\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x11\x00\x02\x40\x42\x2a\x10\x09\x42\x2a\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x15\x00\x02\x40\x42\x90\xe4\x00\x10\x09\x42\x90\xe4\x00\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x13\x00\x02\x40\x42\x7f\x10\x0a\x42\xff\xff\x03\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x14\x00\x02\x40\x42\xee\x5e\x10\x0a\x42\xee\xde\x03\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x11\x00\x02\x40\x42\x2a\x10\x0a\x42\x2a\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x15\x00\x02\x40\x42\xfe\x95\x03\x10\x0a\x42\xfe\x95\x03\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x11\x00\x02\x40\x42\x7f\x10\x0b\x42\x7f\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x17\x00\x02\x40\x42\xce\xd0\xe2\x6b\x10\x0b\x42\xce\xd0\xe2\x6b\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x17\x00\x02\x40\x42\xb2\xaf\x9d\x14\x10\x0b\x42\xb2\xaf\x9d\x14\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x19\x00\x02\x40\x42\xf8\xac\xd1\x91\x01\x10\x0b\x42\xf8\xac\xd1\x91\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x15\x00\x02\x40\x42\x7f\x10\x0c\x42\xff\xff\xff\xff\x0f\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x18\x00\x02\x40\x42\xce\xd0\xe2\x6b\x10\x0c\x42\xce\xd0\xe2\xeb\x0f\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x17\x00\x02\x40\x42\xb2\xaf\x9d\x14\x10\x0c\x42\xb2\xaf\x9d\x14\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x19\x00\x02\x40\x42\xea\xbb\xb4\xdd\x0a\x10\x0c\x42\xea\xbb\xb4\xdd\x0a\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x11\x00\x02\x40\x42\x7f\x10\x0d\x42\x7f\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x17\x00\x02\x40\x42\xce\xd0\xe2\x6b\x10\x0d\x42\xce\xd0\xe2\x6b\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x19\x00\x02\x40\x42\xea\xbb\xb4\xdd\x0a\x10\x0d\x42\xea\xbb\xb4\xdd\x0a\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x23\x00\x02\x40\x42\xea\xbb\xb4\xf5\xed\xdf\xf2\xd6\xab\x7f\x10\x0d\x42\xea\xbb\xb4\xf5\xed\xdf\xf2\xd6\xab\x7f\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x13\x00\x02\x40\x42\x7f\x10\x12\x42\xff\xff\x03\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x14\x00\x02\x40\x42\xee\x5e\x10\x12\x42\xee\xde\x03\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x11\x00\x02\x40\x42\x2a\x10\x12\x42\x2a\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x15\x00\x02\x40\x42\xfe\x95\x03\x10\x12\x42\xfe\x95\x03\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x15\x00\x02\x40\x42\x7f\x10\x13\x42\xff\xff\xff\xff\x0f\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x16\x00\x02\x40\x42\xee\x5e\x10\x13\x42\xee\xde\xff\xff\x0f\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x17\x00\x02\x40\x42\xb2\xaf\x9d\x14\x10\x13\x42\xb2\xaf\x9d\x14\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x19\x00\x02\x40\x42\xfe\x95\xb7\xf5\x0d\x10\x13\x42\xfe\x95\xb7\xf5\x0d\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x11\x00\x02\x40\x42\x7f\x10\x14\x42\x7f\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x17\x00\x02\x40\x42\xce\xd0\xe2\x6b\x10\x14\x42\xce\xd0\xe2\x6b\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x19\x00\x02\x40\x42\xea\xbb\xb4\xdd\x0a\x10\x14\x42\xea\xbb\xb4\xdd\x0a\x51\x45\x0d\x00\x0f\x0b\x00\x0b\x23\x00\x02\x40\x42\xea\xbb\xb4\xf5\xed\xdf\xf2\xd6\xab\x7f\x10\x14\x42\xea\xbb\xb4\xf5\xed\xdf\xf2\xd6\xab\x7f\x51\x45\x0d\x00\x0f\x0b\x00\x0b"); |
| assert_return(() => $$.exports["i32_load16_s"](-1), -1); |
| assert_return(() => $$.exports["i32_load16_s"](-4242), -4242); |
| assert_return(() => $$.exports["i32_load16_s"](42), 42); |
| assert_return(() => $$.exports["i32_load16_s"](12816), 12816); |
| assert_return(() => $$.exports["i32_load16_u"](-1), 65535); |
| assert_return(() => $$.exports["i32_load16_u"](-4242), 61294); |
| assert_return(() => $$.exports["i32_load16_u"](42), 42); |
| assert_return(() => $$.exports["i32_load16_u"](51966), 51966); |
| assert_return(() => $$.exports["i32_load"](-1), -1); |
| assert_return(() => $$.exports["i32_load"](-42424242), -42424242); |
| assert_return(() => $$.exports["i32_load"](42424242), 42424242); |
| assert_return(() => $$.exports["i32_load"](-1414717974), -1414717974); |
| assert_return(() => $$.exports["assert_0"]()); |
| assert_return(() => $$.exports["assert_1"]()); |
| assert_return(() => $$.exports["assert_2"]()); |
| assert_return(() => $$.exports["assert_3"]()); |
| assert_return(() => $$.exports["assert_4"]()); |
| assert_return(() => $$.exports["assert_5"]()); |
| assert_return(() => $$.exports["assert_6"]()); |
| assert_return(() => $$.exports["assert_7"]()); |
| assert_return(() => $$.exports["assert_8"]()); |
| assert_return(() => $$.exports["assert_9"]()); |
| assert_return(() => $$.exports["assert_10"]()); |
| assert_return(() => $$.exports["assert_11"]()); |
| assert_return(() => $$.exports["assert_12"]()); |
| assert_return(() => $$.exports["assert_13"]()); |
| assert_return(() => $$.exports["assert_14"]()); |
| assert_return(() => $$.exports["assert_15"]()); |
| assert_return(() => $$.exports["assert_16"]()); |
| assert_return(() => $$.exports["assert_17"]()); |
| assert_return(() => $$.exports["assert_18"]()); |
| assert_return(() => $$.exports["assert_19"]()); |
| assert_return(() => $$.exports["f32_load"](f32(-1.0)), f32(-1.0)); |
| assert_return(() => $$.exports["f32_load"](f32(0.0123399998993)), f32(0.0123399998993)); |
| assert_return(() => $$.exports["f32_load"](f32(4242.42431641)), f32(4242.42431641)); |
| assert_return(() => $$.exports["f32_load"](f32(3.40282346639e+38)), f32(3.40282346639e+38)); |
| assert_return(() => $$.exports["f64_load"](-1.0), -1.0); |
| assert_return(() => $$.exports["f64_load"](1234.56789), 1234.56789); |
| assert_return(() => $$.exports["f64_load"](424242.424242), 424242.424242); |
| assert_return(() => $$.exports["f64_load"](1.7976931348623157e+308), 1.7976931348623157e+308); |
| assert_return(() => $$.exports["i32_store16"](-1), 65535); |
| assert_return(() => $$.exports["i32_store16"](-4242), 61294); |
| assert_return(() => $$.exports["i32_store16"](42), 42); |
| assert_return(() => $$.exports["i32_store16"](51966), 51966); |
| assert_return(() => $$.exports["i32_store"](-1), -1); |
| assert_return(() => $$.exports["i32_store"](-4242), -4242); |
| assert_return(() => $$.exports["i32_store"](42424242), 42424242); |
| assert_return(() => $$.exports["i32_store"](-559035650), -559035650); |
| assert_return(() => $$.exports["assert_20"]()); |
| assert_return(() => $$.exports["assert_21"]()); |
| assert_return(() => $$.exports["assert_22"]()); |
| assert_return(() => $$.exports["assert_23"]()); |
| assert_return(() => $$.exports["assert_24"]()); |
| assert_return(() => $$.exports["assert_25"]()); |
| assert_return(() => $$.exports["assert_26"]()); |
| assert_return(() => $$.exports["assert_27"]()); |
| assert_return(() => $$.exports["assert_28"]()); |
| assert_return(() => $$.exports["assert_29"]()); |
| assert_return(() => $$.exports["assert_30"]()); |
| assert_return(() => $$.exports["assert_31"]()); |
| assert_return(() => $$.exports["f32_store"](f32(-1.0)), f32(-1.0)); |
| assert_return(() => $$.exports["f32_store"](f32(0.0123399998993)), f32(0.0123399998993)); |
| assert_return(() => $$.exports["f32_store"](f32(4242.42431641)), f32(4242.42431641)); |
| assert_return(() => $$.exports["f32_store"](f32(3.40282346639e+38)), f32(3.40282346639e+38)); |
| assert_return(() => $$.exports["f64_store"](-1.0), -1.0); |
| assert_return(() => $$.exports["f64_store"](1234.56789), 1234.56789); |
| assert_return(() => $$.exports["f64_store"](424242.424242), 424242.424242); |
| assert_return(() => $$.exports["f64_store"](1.7976931348623157e+308), 1.7976931348623157e+308); |