implements PR-08.3
This commit is contained in:
+46
-1
@@ -222,6 +222,41 @@ class LowerToIRVMServiceTest {
|
||||
assertEquals("helper_in_zeta", lowered.module().functions().get(2).name());
|
||||
}
|
||||
|
||||
@Test
|
||||
void lowerMustUseQualifiedEntrypointIdentityWhenProvided() {
|
||||
final var backend = IRBackend.builder()
|
||||
.entryPointCallableName("main")
|
||||
.entryPointModuleId(new ModuleId(1))
|
||||
.modulePool(ReadOnlyList.from(
|
||||
new ModuleReference("app", ReadOnlyList.from("alpha")),
|
||||
new ModuleReference("app", ReadOnlyList.from("beta"))))
|
||||
.executableFunctions(ReadOnlyList.from(
|
||||
fnWithModuleAndLocals("main", "legacy/alpha", 0, 30, 1, ReadOnlyList.from(ret())),
|
||||
fnWithModuleAndLocals("main", "legacy/beta", 1, 31, 9, ReadOnlyList.from(ret())),
|
||||
fnWithModule("helper", "legacy/alpha", 0, 32, ReadOnlyList.from(ret()))))
|
||||
.build();
|
||||
|
||||
final var lowered = new LowerToIRVMService().lower(backend);
|
||||
|
||||
assertEquals("main", lowered.module().functions().get(0).name());
|
||||
assertEquals(9, lowered.module().functions().get(0).localSlots());
|
||||
}
|
||||
|
||||
@Test
|
||||
void lowerMustRejectMissingQualifiedEntrypointIdentity() {
|
||||
final var backend = IRBackend.builder()
|
||||
.entryPointCallableName("main")
|
||||
.entryPointModuleId(new ModuleId(5))
|
||||
.modulePool(ReadOnlyList.from(new ModuleReference("app", ReadOnlyList.from("alpha"))))
|
||||
.executableFunctions(ReadOnlyList.from(
|
||||
fnWithModule("main", "legacy/alpha", 0, 40, ReadOnlyList.from(ret()))))
|
||||
.build();
|
||||
|
||||
final var thrown = assertThrows(IRVMLoweringException.class, () -> new LowerToIRVMService().lower(backend));
|
||||
assertEquals(IRVMLoweringErrorCode.LOWER_IRVM_ENTRYPOINT_MISSING, thrown.code());
|
||||
assertTrue(thrown.getMessage().contains("qualified entrypoint"));
|
||||
}
|
||||
|
||||
private static IRBackendExecutableFunction fn(
|
||||
final String name,
|
||||
final String moduleKey,
|
||||
@@ -248,6 +283,16 @@ class LowerToIRVMServiceTest {
|
||||
final int moduleId,
|
||||
final int callableId,
|
||||
final ReadOnlyList<IRBackendExecutableFunction.Instruction> instructions) {
|
||||
return fnWithModuleAndLocals(name, moduleKey, moduleId, callableId, 0, instructions);
|
||||
}
|
||||
|
||||
private static IRBackendExecutableFunction fnWithModuleAndLocals(
|
||||
final String name,
|
||||
final String moduleKey,
|
||||
final int moduleId,
|
||||
final int callableId,
|
||||
final int localSlots,
|
||||
final ReadOnlyList<IRBackendExecutableFunction.Instruction> instructions) {
|
||||
return new IRBackendExecutableFunction(
|
||||
new FileId(0),
|
||||
new ModuleId(moduleId),
|
||||
@@ -257,7 +302,7 @@ class LowerToIRVMServiceTest {
|
||||
0,
|
||||
10,
|
||||
0,
|
||||
0,
|
||||
localSlots,
|
||||
0,
|
||||
4,
|
||||
instructions,
|
||||
|
||||
Reference in New Issue
Block a user