implements PR-O1.4
This commit is contained in:
+30
-1
@@ -79,6 +79,20 @@ class LowerToIRVMServiceTest {
|
||||
assertEquals(IRVMLoweringErrorCode.LOWER_IRVM_MISSING_CALLEE, thrown.code());
|
||||
}
|
||||
|
||||
@Test
|
||||
void lowerMustRejectCallArgSlotMismatch() {
|
||||
final var backend = IRBackend.builder()
|
||||
.executableFunctions(ReadOnlyList.from(
|
||||
fn("callee", "app", ReadOnlyList.from(ret())),
|
||||
fn("main", "app", ReadOnlyList.from(
|
||||
callFuncWithExpected("app", "callee", 2, 0),
|
||||
ret()))))
|
||||
.build();
|
||||
|
||||
final var thrown = assertThrows(IRVMLoweringException.class, () -> new LowerToIRVMService().lower(backend));
|
||||
assertEquals(IRVMLoweringErrorCode.LOWER_IRVM_CALL_ARG_SLOTS_MISMATCH, thrown.code());
|
||||
}
|
||||
|
||||
private static IRBackendExecutableFunction fn(
|
||||
final String name,
|
||||
final String moduleKey,
|
||||
@@ -117,6 +131,22 @@ class LowerToIRVMServiceTest {
|
||||
Span.none());
|
||||
}
|
||||
|
||||
private static IRBackendExecutableFunction.Instruction callFuncWithExpected(
|
||||
final String moduleKey,
|
||||
final String name,
|
||||
final int expectedArgSlots,
|
||||
final int expectedRetSlots) {
|
||||
return new IRBackendExecutableFunction.Instruction(
|
||||
IRBackendExecutableFunction.InstructionKind.CALL_FUNC,
|
||||
moduleKey,
|
||||
name,
|
||||
null,
|
||||
null,
|
||||
expectedArgSlots,
|
||||
expectedRetSlots,
|
||||
Span.none());
|
||||
}
|
||||
|
||||
private static IRBackendExecutableFunction.Instruction callHost(
|
||||
final String module,
|
||||
final String name,
|
||||
@@ -145,4 +175,3 @@ class LowerToIRVMServiceTest {
|
||||
Span.none());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user