From 33a08d74b30e08a634b83d14a77ecc080aec0050 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 30 Mar 2026 23:04:06 +0100 Subject: Add Patio test for locals --- .../shedlang/compiler/patio/PatioExampleTests.java | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java b/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java index 41185d38..08f4a50f 100644 --- a/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java +++ b/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java @@ -41,6 +41,31 @@ public abstract class PatioExampleTests { )); } + @Test + public void localsAreStoredByName() throws IOException, InterruptedException { + var patioFunction = PatioFunctionDefinition.builder() + .withName(FUNCTION_NAME) + .withReturnType(PatioTypes.VOID) + .addLocal(PatioLocal.val("a", PatioTypes.INT)) + .addLocal(PatioLocal.val("b", PatioTypes.INT)) + .addBodyInstruction(Patio.localStore(Patio.localRef("a"), Patio.intConst(42))) + .addBodyInstruction(Patio.localStore(Patio.localRef("b"), Patio.intConst(47))) + .addBodyInstruction(emitInt(Patio.localRef("a"))) + .addBodyInstruction(emitInt(Patio.localRef("b"))) + .addBodyInstruction(Patio.returnVoid()) + .build(); + var patio = Patio.compilationUnit(List.of( + patioFunction + )); + + var result = run(patio); + + assertThat(result, isSequence( + isInt(42), + isInt(47) + )); + } + @Test public void canLoadDataElementInt() throws IOException, InterruptedException { var patioDataElement = new PatioDataElementImmutableDefinition( -- cgit v1.2.3