Skip to content

Instantly share code, notes, and snippets.

@shelajev
Last active November 13, 2019 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shelajev/67f59d2416d620a94e395417dc96d7d1 to your computer and use it in GitHub Desktop.
Save shelajev/67f59d2416d620a94e395417dc96d7d1 to your computer and use it in GitHub Desktop.
import org.junit.Test;
import static org.junit.Assert.*;
import org.graalvm.polyglot.*;
import org.graalvm.polyglot.io.ByteSequence;
import java.io.IOException;
public class WasmPolyglotTest {
@Test
public void test() throws IOException {
Context.Builder contextBuilder = Context.newBuilder("wasm");
Source.Builder sourceBuilder = Source.newBuilder("wasm",
ByteSequence.create(binary),
"main");
Source source = sourceBuilder.build();
Context context = contextBuilder.build();
context.eval(source);
Value mainFunction = context.getBindings("wasm").getMember("main");
Value result = mainFunction.execute();
assertEquals(42, result.asInt());
}
}
@axel22
Copy link

axel22 commented Nov 13, 2019

We need to rename this class to WasmExampleTest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment