aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-12-15 11:16:06 +0000
committerMichael Williamson <mike@zwobble.org>2023-12-15 11:16:06 +0000
commit7fbdae255cbaf850d88488deb6e2f58defd65f41 (patch)
treecb481431ffcb127352a4c64d5c049f9136df2ddf /src/test/java
parent1dc868ca96048bb9ddbd58b3c74ed965a4e7103a (diff)
Add code gen for Patio blocks
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java24
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)