aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java25
1 files changed, 25 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 41185d38..08f4a50f 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java
@@ -42,6 +42,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(
"answer",