implements PR-O1.2

This commit is contained in:
2026-03-24 13:42:26 +00:00
parent b5c372efb2
commit 9e3d9ccb93
2 changed files with 109 additions and 2 deletions
@@ -7,6 +7,7 @@ import p.studio.utilities.structures.ReadOnlyList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
class IRBackendExecutableContractTest {
@@ -30,6 +31,54 @@ class IRBackendExecutableContractTest {
assertEquals(IRBackendExecutableFunction.InstructionKind.CALL_FUNC, callFunc.kind());
}
@Test
void functionContractMustRejectInvalidSlotAndSpanBounds() {
assertThrows(IllegalArgumentException.class, () -> new IRBackendExecutableFunction(
new FileId(1),
"app",
"main",
10,
5,
0,
0,
0,
1,
ReadOnlyList.empty(),
Span.none()));
final var thrown = assertThrows(IllegalArgumentException.class, () -> new IRBackendExecutableFunction(
new FileId(1),
"app",
"main",
0,
10,
0,
0,
2,
1,
ReadOnlyList.empty(),
Span.none()));
assertTrue(thrown.getMessage().contains("maxStackSlots"));
}
@Test
void instructionContractMustRejectMixedMetadataKinds() {
assertThrows(IllegalArgumentException.class, () -> new IRBackendExecutableFunction.Instruction(
IRBackendExecutableFunction.InstructionKind.CALL_FUNC,
"app/main",
"foo",
new IRBackendExecutableFunction.HostCallMetadata("gfx", "draw", 1, 0, 0),
null,
Span.none()));
assertThrows(IllegalArgumentException.class, () -> new IRBackendExecutableFunction.HostCallMetadata(
"gfx",
"draw",
1,
-1,
0));
}
@Test
void aggregatorMustPreserveExecutableFunctionOrderDeterministically() {
final var fileA = new IRBackendFile(
@@ -87,4 +136,3 @@ class IRBackendExecutableContractTest {
assertEquals("aux", backend.getExecutableFunctions().get(1).callableName());
}
}