From cab0787d8c259b21baa376ba1ec2d95740964bd9 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 2 Feb 2025 19:06:21 +0000 Subject: Add Shid to Patio codegen for relational int operations --- .../ShidToPatioIntGreaterThanOrEqualTests.java | 28 ++++++++++++++++++++++ .../ShidToPatioIntGreaterThanTests.java | 28 ++++++++++++++++++++++ .../ShidToPatioIntLessThanOrEqualTests.java | 28 ++++++++++++++++++++++ .../shidtopatio/ShidToPatioIntLessThanTests.java | 28 ++++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntGreaterThanOrEqualTests.java create mode 100644 src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntGreaterThanTests.java create mode 100644 src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntLessThanOrEqualTests.java create mode 100644 src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntLessThanTests.java (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntGreaterThanOrEqualTests.java b/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntGreaterThanOrEqualTests.java new file mode 100644 index 00000000..3d6f94fe --- /dev/null +++ b/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntGreaterThanOrEqualTests.java @@ -0,0 +1,28 @@ +package org.shedlang.compiler.shidtopatio; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.shedlang.compiler.patio.operands.PatioLocalRef; +import org.shedlang.compiler.shid.instructions.Shid; +import org.shedlang.compiler.testing.snapshots.SnapshotResolver; +import org.shedlang.compiler.testing.snapshots.Snapshotter; + +import java.io.IOException; + +import static org.shedlang.compiler.shidtopatio.ShidToPatioTesting.serialize; + +@ExtendWith({SnapshotResolver.class}) +public class ShidToPatioIntGreaterThanOrEqualTests { + @Test + public void canGenerateCodeForIntGreaterThanOrEqual(Snapshotter snapshotter) throws IOException { + var shid = Shid.intGreaterThanOrEqual(); + var context = ShidToPatioContext.EMPTY + .temporaryPush(new PatioLocalRef("a")) + .temporaryPush(new PatioLocalRef("b")) + .temporaryPush(new PatioLocalRef("c")); + + var result = ShidToPatio.generateInstruction(shid, context); + + snapshotter.assertSnapshot(serialize(result)); + } +} diff --git a/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntGreaterThanTests.java b/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntGreaterThanTests.java new file mode 100644 index 00000000..6d0ce238 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntGreaterThanTests.java @@ -0,0 +1,28 @@ +package org.shedlang.compiler.shidtopatio; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.shedlang.compiler.patio.operands.PatioLocalRef; +import org.shedlang.compiler.shid.instructions.Shid; +import org.shedlang.compiler.testing.snapshots.SnapshotResolver; +import org.shedlang.compiler.testing.snapshots.Snapshotter; + +import java.io.IOException; + +import static org.shedlang.compiler.shidtopatio.ShidToPatioTesting.serialize; + +@ExtendWith({SnapshotResolver.class}) +public class ShidToPatioIntGreaterThanTests { + @Test + public void canGenerateCodeForIntGreaterThan(Snapshotter snapshotter) throws IOException { + var shid = Shid.intGreaterThan(); + var context = ShidToPatioContext.EMPTY + .temporaryPush(new PatioLocalRef("a")) + .temporaryPush(new PatioLocalRef("b")) + .temporaryPush(new PatioLocalRef("c")); + + var result = ShidToPatio.generateInstruction(shid, context); + + snapshotter.assertSnapshot(serialize(result)); + } +} diff --git a/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntLessThanOrEqualTests.java b/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntLessThanOrEqualTests.java new file mode 100644 index 00000000..f77bd025 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntLessThanOrEqualTests.java @@ -0,0 +1,28 @@ +package org.shedlang.compiler.shidtopatio; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.shedlang.compiler.patio.operands.PatioLocalRef; +import org.shedlang.compiler.shid.instructions.Shid; +import org.shedlang.compiler.testing.snapshots.SnapshotResolver; +import org.shedlang.compiler.testing.snapshots.Snapshotter; + +import java.io.IOException; + +import static org.shedlang.compiler.shidtopatio.ShidToPatioTesting.serialize; + +@ExtendWith({SnapshotResolver.class}) +public class ShidToPatioIntLessThanOrEqualTests { + @Test + public void canGenerateCodeForIntLessThanOrEqual(Snapshotter snapshotter) throws IOException { + var shid = Shid.intLessThanOrEqual(); + var context = ShidToPatioContext.EMPTY + .temporaryPush(new PatioLocalRef("a")) + .temporaryPush(new PatioLocalRef("b")) + .temporaryPush(new PatioLocalRef("c")); + + var result = ShidToPatio.generateInstruction(shid, context); + + snapshotter.assertSnapshot(serialize(result)); + } +} diff --git a/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntLessThanTests.java b/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntLessThanTests.java new file mode 100644 index 00000000..82b64c1d --- /dev/null +++ b/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntLessThanTests.java @@ -0,0 +1,28 @@ +package org.shedlang.compiler.shidtopatio; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.shedlang.compiler.patio.operands.PatioLocalRef; +import org.shedlang.compiler.shid.instructions.Shid; +import org.shedlang.compiler.testing.snapshots.SnapshotResolver; +import org.shedlang.compiler.testing.snapshots.Snapshotter; + +import java.io.IOException; + +import static org.shedlang.compiler.shidtopatio.ShidToPatioTesting.serialize; + +@ExtendWith({SnapshotResolver.class}) +public class ShidToPatioIntLessThanTests { + @Test + public void canGenerateCodeForIntLessThan(Snapshotter snapshotter) throws IOException { + var shid = Shid.intLessThan(); + var context = ShidToPatioContext.EMPTY + .temporaryPush(new PatioLocalRef("a")) + .temporaryPush(new PatioLocalRef("b")) + .temporaryPush(new PatioLocalRef("c")); + + var result = ShidToPatio.generateInstruction(shid, context); + + snapshotter.assertSnapshot(serialize(result)); + } +} -- cgit v1.2.3