diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-04-03 10:17:03 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-04-03 10:17:03 +0100 |
| commit | 698bec55c1d6fe07016b9d27a493ad927530ac7a (patch) | |
| tree | f1b4928e808b796abf885bbe52ca8f33ba626c1d /src | |
| parent | db4001cc5a801626d4c25274eb63b7c3e23a858c (diff) | |
Add Patio tests for int-not-equal
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/patio/PatioExampleTests.java | 47 |
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) |
