diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-04-05 21:37:17 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-04-05 21:42:10 +0100 |
| commit | 10d5eca372ed85d9beab8f91e0cadcd6f8e24fac (patch) | |
| tree | 9204c7a1f716bb7182c46e9ae00614cdaf8e48b0 /src/test | |
| parent | 197ddfce216d81f57691261a931f23bbe855bdfa (diff) | |
Support null data pointer
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java | 21 | ||||
| -rw-r--r-- | src/test/java/org/shedlang/compiler/patio/instructions/Patio.java | 4 |
2 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 9ea6aef2..0cc1574d 100644 --- a/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java +++ b/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java @@ -143,6 +143,27 @@ public abstract class PatioExampleTests { } @Test + public void dataPtrCanBeNull() throws IOException, InterruptedException { + var patioFunction = PatioFunctionDefinition.builder() + .withName(FUNCTION_NAME) + .addLocal(PatioLocal.val("x", PatioTypes.DATA_PTR)) + .addBodyInstruction(Patio.localStore( + Patio.localRef("x"), + Patio.dataPtrConst(Patio.dataPtrValueNull()) + )) + .withReturnType(PatioTypes.VOID) + .addBodyInstruction(Patio.returnVoid()) + .build(); + var patio = Patio.compilationUnit(List.of( + patioFunction + )); + + var result = run(patio); + + assertThat(result, isSequence()); + } + + @Test public void blockSingleResult() throws IOException, InterruptedException { var patioFunction = PatioFunctionDefinition.builder() .withName(FUNCTION_NAME) diff --git a/src/test/java/org/shedlang/compiler/patio/instructions/Patio.java b/src/test/java/org/shedlang/compiler/patio/instructions/Patio.java index f8f8dbf6..d6d236c6 100644 --- a/src/test/java/org/shedlang/compiler/patio/instructions/Patio.java +++ b/src/test/java/org/shedlang/compiler/patio/instructions/Patio.java @@ -119,6 +119,10 @@ public class Patio { return PatioDataPtrConst.dataElement(name); } + public static PatioOperand dataPtrConst(PatioDataPtrValue value) { + return new PatioDataPtrConst(value); + } + public static PatioInstruction dataPtrToInt(PatioLocalRef destination, PatioOperand value) { return new PatioDataPtrToInt( destination, |
