diff options
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java | 24 |
1 files changed, 24 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 729b4b87..95354c51 100644 --- a/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java +++ b/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java @@ -69,6 +69,30 @@ public abstract class PatioExampleTests { } @Test + public void block() throws IOException, InterruptedException { + var patioFunction = PatioFunctionDefinition.builder() + .withName(FUNCTION_NAME) + .withReturnType(PatioTypes.INT) + .addLocal(Patio.val("x", PatioTypes.INT)) + .addBodyInstruction(Patio.block( + List.of( + Patio.localStore( + Patio.localRef("x"), + Patio.int_(42) + ) + ), + List.of(Patio.localRef("x")) + )) + .addBodyInstruction(Patio.return_(Patio.localRef("x"))) + .build(); + var patio = Patio.compilationUnit(List.of(patioFunction)); + + var result = run(patio); + + assertThat(result, isSilentExit(42)); + } + + @Test public void intAdd() throws IOException, InterruptedException { var patioFunction = PatioFunctionDefinition.builder() .withName(FUNCTION_NAME) |
