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
| Value mainFunction = context.getBindings("wasm").getMember("main"); | |
| Object result = mainFunction.execute(); |
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"); |
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
| long fact(long n) { | |
| if (n == 0) | |
| return 1L; | |
| else | |
| return n * fact(n - 1); | |
| } |
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
| public static void main(String[] args) throws Exception { | |
| int cnt = Integer.parseInt(args[0]); | |
| long seed = Long.parseLong(args[1]); | |
| int repeat = Integer.parseInt(args[2]); | |
| Shape[] samples = generate(3, args, cnt, seed); | |
| double expected = computeArea(samples); | |
| long prev = System.currentTimeMillis(); | |
| for (int i = 0; i < repeat * 1000; i++) { | |
| double sum = computeArea(samples); | |
| if (sum != expected) { |
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
| static double computeArea(Shape[] all) { | |
| double sum = 0; | |
| for (Shape shape : all) { | |
| sum += shape.area(); | |
| } | |
| return sum; | |
| } |
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
| abstract class Shape { | |
| public abstract double area(); | |
| public static Shape cicle(double radius) { | |
| return new Circle(radius); | |
| } | |
| public static Shape square(double side) { | |
| return new Square(side); | |
| } | |
| public static Shape rectangle(double a, double b) { | |
| return new Rectangle(a, b); |
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
| package example | |
| object Hello extends App { | |
| println(System.getProperty("java.home")) | |
| } |
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
| generic = Java.type('org.testcontainers.containers.GenericContainer') | |
| container = generic.new('nginx') | |
| container.setExposedPorts([80]) | |
| container.start(); | |
| puts "#{container.getContainerIpAddress()}:#{container.getMappedPort(80)}" |
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 java | |
| generic = java.type('org.testcontainers.containers.GenericContainer') | |
| container = generic('nginx') | |
| container.setExposedPorts([80]) | |
| container.start(); | |
| print('%s:%s' % (container.getContainerIpAddress(), container.getMappedPort(80))); |
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
| ImageName = netty-plot | |
| Args = --features=com.oracle.svm.nettyplot.PlotterSingletonFeature -H:+SpawnIsolates |