Skip to content

Commit

Permalink
Extending tests of func_type().
Browse files Browse the repository at this point in the history
  • Loading branch information
iamstolis committed Jul 18, 2021
1 parent 67b37c3 commit 3fe33b1
Showing 1 changed file with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ public void testMemoryAllocationFailure() {
}

@Test
public void testFuncType() throws IOException {
public void testFuncTypeTable() throws IOException {
runTest(context -> {
final WebAssembly wasm = new WebAssembly(context);
final WebAssemblyInstantiatedSource instantiatedSource = wasm.instantiate(binaryWithTableExport, null);
Expand All @@ -823,7 +823,28 @@ public void testFuncType() throws IOException {
final Object funcType = wasm.readMember("func_type");
final Table table = (Table) instance.exports().readMember("defaultTable");
final Object fn = table.get(0);
Assert.assertEquals("func_type", "0(i32)i32", InteropLibrary.getUncached(funcType).execute(funcType, fn));
InteropLibrary interop = InteropLibrary.getUncached(funcType);
Assert.assertEquals("func_type", "0(i32)i32", interop.execute(funcType, fn));
// set + get should not break func_type()
table.set(0, fn);
final Object fnAgain = table.get(0);
Assert.assertEquals("func_type", "0(i32)i32", interop.execute(funcType, fnAgain));
} catch (InteropException e) {
throw new RuntimeException(e);
}
});
}

@Test
public void testFuncTypeExport() throws IOException {
runTest(context -> {
final WebAssembly wasm = new WebAssembly(context);
final WebAssemblyInstantiatedSource instantiatedSource = wasm.instantiate(binaryWithMemoryExport, null);
final Instance instance = instantiatedSource.instance();
try {
final Object funcType = wasm.readMember("func_type");
final Object fn = instance.exports().readMember("readZero");
Assert.assertEquals("func_type", "0()i32", InteropLibrary.getUncached(funcType).execute(funcType, fn));
} catch (InteropException e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit 3fe33b1

Please sign in to comment.