diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-04-03 10:11:21 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-04-03 10:11:21 +0100 |
| commit | cccf9edd15ad2148dadd09fa5a2a94edf9dbbf77 (patch) | |
| tree | 4900f9eb56c8036895dc11cec89de0868710cdf3 /src | |
| parent | fa422910d1bdd99967016b9c1f8985ce2351fb04 (diff) | |
Compile int-sub in patio-to-cranelift
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java | 33 |
1 files changed, 33 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 08f4a50f..25219c9e 100644 --- a/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java +++ b/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java @@ -366,6 +366,39 @@ public abstract class PatioExampleTests { } @Test + public void intSub() throws IOException, InterruptedException { + var patioFunction = PatioFunctionDefinition.builder() + .withName(FUNCTION_NAME) + .withReturnType(PatioTypes.VOID) + .addLocal(Patio.val("x", PatioTypes.INT)) + .addLocal(Patio.val("y", PatioTypes.INT)) + .addLocal(Patio.val("z", PatioTypes.INT)) + .addBodyInstruction(Patio.localStore( + Patio.localRef("x"), + Patio.intConst(47) + )) + .addBodyInstruction(Patio.localStore( + Patio.localRef("y"), + Patio.intConst(5) + )) + .addBodyInstruction(Patio.intSub( + Patio.localRef("z"), + Patio.localRef("x"), + Patio.localRef("y") + )) + .addBodyInstruction(emitInt(Patio.localRef("z"))) + .addBodyInstruction(Patio.returnVoid()) + .build(); + var patio = Patio.compilationUnit(List.of(patioFunction)); + + var result = run(patio); + + assertThat(result, isSequence( + isInt(42) + )); + } + + @Test public void switchWithUnreachableDefault() throws IOException, InterruptedException { var patioFunction = PatioFunctionDefinition.builder() .withName(FUNCTION_NAME) |
