ladybird/Libraries/LibWasm/Tests/Executor/test-memory_fill-order.js
Ali Mohammad Pur 31da9ab4e8 LibWasm: Take memory_fill arguments in the right order
This makes ruffle.rs work again :^)
2025-10-04 11:17:08 +02:00

23 lines
913 B
JavaScript

test("memfill executes and returns expected result", () => {
const bin = readBinaryWasmFile("Fixtures/Modules/memory_fill-order.wasm");
const module = parseWebAssemblyModule(bin);
const test_fill = module.getExport("test_fill");
// memory.fill off=10 value=42 size=5
module.invoke(test_fill);
const get_value = module.getExport("get_value");
// After memory.fill, bytes 10..14 should be filled with value 42
expect(module.invoke(get_value, 10)).toBe(42);
expect(module.invoke(get_value, 11)).toBe(42);
expect(module.invoke(get_value, 12)).toBe(42);
expect(module.invoke(get_value, 13)).toBe(42);
expect(module.invoke(get_value, 14)).toBe(42);
// Byte 9 (before the fill region) should still be 0
expect(module.invoke(get_value, 9)).toBe(0);
// Byte 15 (after the fill region) should still be 0
expect(module.invoke(get_value, 15)).toBe(0);
});