blob: 46ad917f707b2a7b61d45e53e4373dc6239f8252 [file] [log] [blame]
/* 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\x0d\x00\x00\x00\x01\x10\x03\x60\x02\x7f\x7f\x01\x7f\x60\x02\x7e\x7e\x01\x7e\x60\x00\x00\x03\x07\x06\x00\x00\x01\x01\x02\x02\x07\x63\x06\x10\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x33\x32\x2e\x64\x69\x76\x5f\x73\x00\x00\x10\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x33\x32\x2e\x64\x69\x76\x5f\x75\x00\x01\x10\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x36\x34\x2e\x64\x69\x76\x5f\x73\x00\x02\x10\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x36\x34\x2e\x64\x69\x76\x5f\x75\x00\x03\x08\x61\x73\x73\x65\x72\x74\x5f\x30\x00\x04\x08\x61\x73\x73\x65\x72\x74\x5f\x31\x00\x05\x0a\x37\x06\x07\x00\x20\x00\x20\x01\x6d\x0b\x07\x00\x20\x00\x20\x01\x6e\x0b\x07\x00\x20\x00\x20\x01\x7f\x0b\x07\x00\x20\x00\x20\x01\x80\x0b\x0a\x00\x42\x01\x42\x00\x10\x02\x0c\x00\x0b\x0a\x00\x42\x01\x42\x00\x10\x03\x0c\x00\x0b");
assert_trap(() => $$.exports["no_dce.i32.div_s"](1, 0));
assert_trap(() => $$.exports["no_dce.i32.div_u"](1, 0));
assert_trap(() => $$.exports["assert_0"]());
assert_trap(() => $$.exports["assert_1"]());
$$ = instance("\x00\x61\x73\x6d\x0d\x00\x00\x00\x01\x10\x03\x60\x02\x7f\x7f\x01\x7f\x60\x02\x7e\x7e\x01\x7e\x60\x00\x00\x03\x07\x06\x00\x00\x01\x01\x02\x02\x07\x63\x06\x10\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x33\x32\x2e\x72\x65\x6d\x5f\x73\x00\x00\x10\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x33\x32\x2e\x72\x65\x6d\x5f\x75\x00\x01\x10\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x36\x34\x2e\x72\x65\x6d\x5f\x73\x00\x02\x10\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x36\x34\x2e\x72\x65\x6d\x5f\x75\x00\x03\x08\x61\x73\x73\x65\x72\x74\x5f\x30\x00\x04\x08\x61\x73\x73\x65\x72\x74\x5f\x31\x00\x05\x0a\x37\x06\x07\x00\x20\x00\x20\x01\x6f\x0b\x07\x00\x20\x00\x20\x01\x70\x0b\x07\x00\x20\x00\x20\x01\x81\x0b\x07\x00\x20\x00\x20\x01\x82\x0b\x0a\x00\x42\x01\x42\x00\x10\x02\x0c\x00\x0b\x0a\x00\x42\x01\x42\x00\x10\x03\x0c\x00\x0b");
assert_trap(() => $$.exports["no_dce.i32.rem_s"](1, 0));
assert_trap(() => $$.exports["no_dce.i32.rem_u"](1, 0));
assert_trap(() => $$.exports["assert_0"]());
assert_trap(() => $$.exports["assert_1"]());
$$ = instance("\x00\x61\x73\x6d\x0d\x00\x00\x00\x01\x18\x05\x60\x01\x7d\x01\x7f\x60\x01\x7c\x01\x7f\x60\x01\x7d\x01\x7e\x60\x01\x7c\x01\x7e\x60\x00\x00\x03\x11\x10\x00\x00\x01\x01\x02\x02\x03\x03\x04\x04\x04\x04\x04\x04\x04\x04\x07\xa1\x02\x10\x16\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x33\x32\x2e\x74\x72\x75\x6e\x63\x5f\x73\x5f\x66\x33\x32\x00\x00\x16\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x33\x32\x2e\x74\x72\x75\x6e\x63\x5f\x75\x5f\x66\x33\x32\x00\x01\x16\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x33\x32\x2e\x74\x72\x75\x6e\x63\x5f\x73\x5f\x66\x36\x34\x00\x02\x16\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x33\x32\x2e\x74\x72\x75\x6e\x63\x5f\x75\x5f\x66\x36\x34\x00\x03\x16\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x36\x34\x2e\x74\x72\x75\x6e\x63\x5f\x73\x5f\x66\x33\x32\x00\x04\x16\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x36\x34\x2e\x74\x72\x75\x6e\x63\x5f\x75\x5f\x66\x33\x32\x00\x05\x16\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x36\x34\x2e\x74\x72\x75\x6e\x63\x5f\x73\x5f\x66\x36\x34\x00\x06\x16\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x36\x34\x2e\x74\x72\x75\x6e\x63\x5f\x75\x5f\x66\x36\x34\x00\x07\x08\x61\x73\x73\x65\x72\x74\x5f\x30\x00\x08\x08\x61\x73\x73\x65\x72\x74\x5f\x31\x00\x09\x08\x61\x73\x73\x65\x72\x74\x5f\x32\x00\x0a\x08\x61\x73\x73\x65\x72\x74\x5f\x33\x00\x0b\x08\x61\x73\x73\x65\x72\x74\x5f\x34\x00\x0c\x08\x61\x73\x73\x65\x72\x74\x5f\x35\x00\x0d\x08\x61\x73\x73\x65\x72\x74\x5f\x36\x00\x0e\x08\x61\x73\x73\x65\x72\x74\x5f\x37\x00\x0f\x0a\xa1\x01\x10\x05\x00\x20\x00\xa8\x0b\x05\x00\x20\x00\xa9\x0b\x05\x00\x20\x00\xaa\x0b\x05\x00\x20\x00\xab\x0b\x05\x00\x20\x00\xae\x0b\x05\x00\x20\x00\xaf\x0b\x05\x00\x20\x00\xb0\x0b\x05\x00\x20\x00\xb1\x0b\x0b\x00\x43\x00\x00\xc0\x7f\x10\x00\x0c\x00\x0b\x0b\x00\x43\x00\x00\xc0\x7f\x10\x01\x0c\x00\x0b\x0f\x00\x44\x00\x00\x00\x00\x00\x00\xf8\x7f\x10\x02\x0c\x00\x0b\x0f\x00\x44\x00\x00\x00\x00\x00\x00\xf8\x7f\x10\x03\x0c\x00\x0b\x0b\x00\x43\x00\x00\xc0\x7f\x10\x04\x0c\x00\x0b\x0b\x00\x43\x00\x00\xc0\x7f\x10\x05\x0c\x00\x0b\x0f\x00\x44\x00\x00\x00\x00\x00\x00\xf8\x7f\x10\x06\x0c\x00\x0b\x0f\x00\x44\x00\x00\x00\x00\x00\x00\xf8\x7f\x10\x07\x0c\x00\x0b");
assert_trap(() => $$.exports["assert_0"]());
assert_trap(() => $$.exports["assert_1"]());
assert_trap(() => $$.exports["assert_2"]());
assert_trap(() => $$.exports["assert_3"]());
assert_trap(() => $$.exports["assert_4"]());
assert_trap(() => $$.exports["assert_5"]());
assert_trap(() => $$.exports["assert_6"]());
assert_trap(() => $$.exports["assert_7"]());
$$ = instance("\x00\x61\x73\x6d\x0d\x00\x00\x00\x01\x15\x04\x60\x01\x7f\x01\x7f\x60\x01\x7f\x01\x7e\x60\x01\x7f\x01\x7d\x60\x01\x7f\x01\x7c\x03\x05\x04\x00\x01\x02\x03\x05\x03\x01\x00\x01\x07\x49\x04\x0f\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x33\x32\x2e\x6c\x6f\x61\x64\x00\x00\x0f\x6e\x6f\x5f\x64\x63\x65\x2e\x69\x36\x34\x2e\x6c\x6f\x61\x64\x00\x01\x0f\x6e\x6f\x5f\x64\x63\x65\x2e\x66\x33\x32\x2e\x6c\x6f\x61\x64\x00\x02\x0f\x6e\x6f\x5f\x64\x63\x65\x2e\x66\x36\x34\x2e\x6c\x6f\x61\x64\x00\x03\x0a\x21\x04\x07\x00\x20\x00\x28\x02\x00\x0b\x07\x00\x20\x00\x29\x03\x00\x0b\x07\x00\x20\x00\x2a\x02\x00\x0b\x07\x00\x20\x00\x2b\x03\x00\x0b");
assert_trap(() => $$.exports["no_dce.i32.load"](65536));
assert_trap(() => $$.exports["no_dce.i64.load"](65536));
assert_trap(() => $$.exports["no_dce.f32.load"](65536));
assert_trap(() => $$.exports["no_dce.f64.load"](65536));