implements PR-O3.3

This commit is contained in:
2026-03-24 13:42:27 +00:00
parent 0df936e36f
commit a79a19cd4f
4 changed files with 99 additions and 3 deletions
@@ -4,6 +4,7 @@ import org.junit.jupiter.api.Test;
import p.studio.utilities.structures.ReadOnlyList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
class IRVMValidatorTest {
@@ -84,5 +85,41 @@ class IRVMValidatorTest {
final var thrown = assertThrows(IRVMValidationException.class, () -> validator.validate(module, true));
assertEquals(IRVMValidationErrorCode.MARSHAL_VERIFY_PRECHECK_INTERNAL_OPCODE_RESIDUAL, thrown.code());
}
}
@Test
void validateMustRejectOpcodeOutsideProfileFeatureGate() {
final var module = new IRVMModule(
"core-v1",
ReadOnlyList.from(
new IRVMFunction(
"main",
0,
0,
0,
1,
ReadOnlyList.from(
new IRVMInstruction(IRVMOp.INTERNAL_EXT, null),
new IRVMInstruction(IRVMOp.HALT, null)))));
final var thrown = assertThrows(IRVMValidationException.class, () -> validator.validate(module, false));
assertEquals(IRVMValidationErrorCode.MARSHAL_VERIFY_PRECHECK_OPCODE_NOT_ALLOWED_FOR_PROFILE, thrown.code());
}
@Test
void validateMayAllowProfileSpecificOpcodeWhenProfileSupportsIt() {
final var module = new IRVMModule(
"experimental-v1",
ReadOnlyList.from(
new IRVMFunction(
"main",
0,
0,
0,
1,
ReadOnlyList.from(
new IRVMInstruction(IRVMOp.INTERNAL_EXT, null),
new IRVMInstruction(IRVMOp.HALT, null)))));
assertDoesNotThrow(() -> validator.validate(module, false));
}
}