aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-04-03 10:11:21 +0100
committerMichael Williamson <mike@zwobble.org>2026-04-03 10:11:21 +0100
commitcccf9edd15ad2148dadd09fa5a2a94edf9dbbf77 (patch)
tree4900f9eb56c8036895dc11cec89de0868710cdf3 /src
parentfa422910d1bdd99967016b9c1f8985ce2351fb04 (diff)
Compile int-sub in patio-to-cranelift
Diffstat (limited to 'src')
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java33
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)