Last active
November 13, 2019 09:54
-
-
Save shelajev/67f59d2416d620a94e395417dc96d7d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We need to rename this class to
WasmExampleTest