aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-04-03 10:17:03 +0100
committerMichael Williamson <mike@zwobble.org>2026-04-03 10:17:03 +0100
commit698bec55c1d6fe07016b9d27a493ad927530ac7a (patch)
treef1b4928e808b796abf885bbe52ca8f33ba626c1d /src
parentdb4001cc5a801626d4c25274eb63b7c3e23a858c (diff)
Add Patio tests for int-not-equal
Diffstat (limited to 'src')
-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 838b4606..9ea6aef2 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java
@@ -413,6 +413,53 @@ public abstract class PatioExampleTests {
}
@Test
+ public void intNotEqual() throws IOException, InterruptedException {
+ assertIntNotEqual(42, 47, 1);
+ assertIntNotEqual(42, 42, 0);
+ }
+
+ private void assertIntNotEqual(
+ 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.intNotEqual(
+ 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)