From 698bec55c1d6fe07016b9d27a493ad927530ac7a Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 3 Apr 2026 10:17:03 +0100 Subject: Add Patio tests for int-not-equal --- .../shedlang/compiler/patio/PatioExampleTests.java | 47 ++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/test/java') 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 @@ -412,6 +412,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() -- cgit v1.2.3