diff options
| -rw-r--r-- | src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java b/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java index eed0e9f3..7d82bbae 100644 --- a/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java +++ b/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java @@ -1,5 +1,6 @@ package org.shedlang.compiler.patio; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.shedlang.compiler.patio.instructions.Patio; import org.shedlang.compiler.patio.instructions.PatioInstruction; @@ -822,6 +823,45 @@ public abstract class PatioExampleTests { )); } + @Disabled + @Test + public void canCallFunctionWithMultipleReturnValuesDefinedInModule() throws IOException, InterruptedException { + var calledFunction = PatioFunctionDefinition.builder() + .withName("f") + .addLocal(PatioLocal.param("x", PatioTypes.INT)) + .addLocal(PatioLocal.val("xPlus5", PatioTypes.INT)) + .addReturnType(PatioTypes.INT) + .addReturnType(PatioTypes.INT) + .addBodyInstruction(Patio.intAdd(Patio.localRef("xPlus5"), Patio.localRef("x"), Patio.intConst(5))) + .addBodyInstruction(Patio.return_(List.of( + Patio.localRef("x"), + Patio.localRef("xPlus5") + ))) + .build(); + + var patioFunction = PatioFunctionDefinition.builder() + .withName(FUNCTION_NAME) + .addLocal(Patio.val("x", PatioTypes.INT)) + .addLocal(Patio.val("y", PatioTypes.INT)) + .addBodyInstruction(Patio.call( + List.of(Patio.localRef("x"), Patio.localRef("y")), + calledFunction.name(), + List.of(Patio.intConst(42)) + )) + .addBodyInstruction(emitInt(Patio.localRef("x"))) + .addBodyInstruction(emitInt(Patio.localRef("y"))) + .addBodyInstruction(Patio.returnVoid()) + .build(); + var patio = Patio.compilationUnit(List.of(calledFunction, patioFunction)); + + var result = run(patio); + + assertThat(result, isSequence( + isInt(42), + isInt(47) + )); + } + @Test public void canCallPointerToFunctionDefinedInModule() throws IOException, InterruptedException { var calledFunction = PatioFunctionDefinition.builder() |
