aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-04-03 10:16:07 +0100
committerMichael Williamson <mike@zwobble.org>2026-04-03 10:16:07 +0100
commitdb4001cc5a801626d4c25274eb63b7c3e23a858c (patch)
tree3c778acae6005773eb7be0efd500e98f17d5c8f8 /src/test/java/org
parentcccf9edd15ad2148dadd09fa5a2a94edf9dbbf77 (diff)
Add Patio tests for int-equals
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java47
1 files changed, 47 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 25219c9e..838b4606 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java
@@ -366,6 +366,53 @@ public abstract class PatioExampleTests {
}
@Test
+ public void intEquals() throws IOException, InterruptedException {
+ assertIntEquals(42, 47, 0);
+ assertIntEquals(42, 42, 1);
+ }
+
+ private void assertIntEquals(
+ int left,
+ int right,
+ int expected
+ ) 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_bool", PatioTypes.BOOL))
+ .addLocal(Patio.val("z_int", PatioTypes.INT))
+ .addBodyInstruction(Patio.localStore(
+ Patio.localRef("x"),
+ Patio.intConst(left)
+ ))
+ .addBodyInstruction(Patio.localStore(
+ Patio.localRef("y"),
+ Patio.intConst(right)
+ ))
+ .addBodyInstruction(Patio.intEquals(
+ Patio.localRef("z_bool"),
+ Patio.localRef("x"),
+ Patio.localRef("y")
+ ))
+ .addBodyInstruction(Patio.boolToInt(
+ Patio.localRef("z_int"),
+ Patio.localRef("z_bool")
+ ))
+ .addBodyInstruction(emitInt(Patio.localRef("z_int")))
+ .addBodyInstruction(Patio.returnVoid())
+ .build();
+ var patio = Patio.compilationUnit(List.of(patioFunction));
+
+ var result = run(patio);
+
+ assertThat(result, isSequence(
+ isInt(expected)
+ ));
+ }
+
+ @Test
public void intSub() throws IOException, InterruptedException {
var patioFunction = PatioFunctionDefinition.builder()
.withName(FUNCTION_NAME)