Truly independent web browser
test("a v128 global is the unsigned 128-bit integer with the low half first", () => {
// (global (export "one") v128 (v128.const i64x2 1 0))
// (global (export "high_half") v128 (v128.const i64x2 0 1))
// (global (export "all_bits") v128 (v128.const i64x2 -1 -1))
// prettier-ignore
const binary = new Uint8Array([
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x06, 0x40, 0x03, 0x7b,
0x00, 0xfd, 0x0c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x7b, 0x00, 0xfd, 0x0c,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0b, 0x7b, 0x00, 0xfd, 0x0c, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x0b, 0x07, 0x1e, 0x03, 0x03, 0x6f, 0x6e, 0x65, 0x03, 0x00, 0x09,
0x68, 0x69, 0x67, 0x68, 0x5f, 0x68, 0x61, 0x6c, 0x66, 0x03, 0x01, 0x08,
0x61, 0x6c, 0x6c, 0x5f, 0x62, 0x69, 0x74, 0x73, 0x03, 0x02
]);
const module = parseWebAssemblyModule(binary);
expect(module.getExport("one")).toBe(1n);
expect(module.getExport("high_half")).toBe(1n << 64n);
expect(module.getExport("all_bits")).toBe((1n << 128n) - 1n);
});