use of org.graalvm.wasm.api.ModuleImportDescriptor in project graal by oracle.
the class WasmJsApiSuite method testImportOrder.
@Test
public void testImportOrder() throws IOException {
runTest(context -> {
final WebAssembly wasm = new WebAssembly(context);
final WasmModule module = wasm.moduleDecode(binaryWithMixedImports);
final Sequence<ModuleImportDescriptor> moduleImports = WebAssembly.moduleImports(module);
String[] expected = new String[] { "f1", "g1", "t", "m", "g2", "f2" };
try {
Assert.assertEquals("Must import all members.", 6L, moduleImports.getArraySize());
for (int i = 0; i < moduleImports.getArraySize(); i++) {
Assert.assertEquals("Module member " + i + " should correspond to the expected import.", expected[i], ((ModuleImportDescriptor) moduleImports.readArrayElement(i)).name());
}
} catch (InvalidArrayIndexException e) {
throw new RuntimeException(e);
}
});
}
Aggregations