File size: 1,286 Bytes
92d9567 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | package vm;
import org.junit.Test;
import static org.junit.Assert.*;
public class MainTest {
@Test
public void testExecuteReturnsResult() {
String result = Main.execute("int x = 2 + 2;");
assertNotNull(result);
assertTrue(result.contains("executed"));
assertTrue(result.contains("4 chars"));
}
@Test
public void testCapabilityRequest() {
// Capability.request is native (WASM import) — in unit tests it throws
// This test verifies the class loads and the method signature is correct
try {
Capability.request("search", "{\"query\":\"test\"}");
fail("Should throw UnsatisfiedLinkError in unit test (native WASM import)");
} catch (UnsatisfiedLinkError e) {
// Expected — native methods only work in WASM runtime
assertTrue(e.getMessage().contains("vm"));
}
}
@Test
public void testWasmClassLoads() {
// Wasm.memorySize is native — verify class loads
try {
Wasm.memorySize();
fail("Should throw UnsatisfiedLinkError in unit test");
} catch (UnsatisfiedLinkError e) {
assertTrue(e.getMessage().contains("vm"));
}
}
}
|