diff options
| author | Michael Williamson <mike@zwobble.org> | 2025-02-02 19:40:59 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2025-02-02 20:13:20 +0000 |
| commit | 28bab9378c84646b274efabd054f388125514781 (patch) | |
| tree | fa3054f45f108b8f5849badd287db7f691e8513a /src/test/java | |
| parent | f303731ca75c91af2584690fb9f1cd3e2c6217c8 (diff) | |
Add Shid int-mul instruction
Diffstat (limited to 'src/test/java')
3 files changed, 41 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/shid/ShidSerializerTests.java b/src/test/java/org/shedlang/compiler/shid/ShidSerializerTests.java index 55b828b4..3fc45b0b 100644 --- a/src/test/java/org/shedlang/compiler/shid/ShidSerializerTests.java +++ b/src/test/java/org/shedlang/compiler/shid/ShidSerializerTests.java @@ -295,6 +295,15 @@ public class ShidSerializerTests { } @Test + public void canSerializeIntMultiply() { + var instruction = Shid.intMultiply(); + + var string = serialize(instruction); + + assertThat(string, equalTo("(int-mul)")); + } + + @Test public void canSerializeIntNotEqual() { var instruction = Shid.intNotEqual(); diff --git a/src/test/java/org/shedlang/compiler/shid/instructions/Shid.java b/src/test/java/org/shedlang/compiler/shid/instructions/Shid.java index 761769ad..51f8ba00 100644 --- a/src/test/java/org/shedlang/compiler/shid/instructions/Shid.java +++ b/src/test/java/org/shedlang/compiler/shid/instructions/Shid.java @@ -111,6 +111,10 @@ public class Shid { return new ShidIntLessThanOrEqual(Sources.NULL); } + public static ShidInstruction intMultiply() { + return new ShidIntMultiply(Sources.NULL); + } + public static ShidInstruction intNotEqual() { return new ShidIntNotEqual(Sources.NULL); } diff --git a/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntMultiplyTests.java b/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntMultiplyTests.java new file mode 100644 index 00000000..09662a98 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioIntMultiplyTests.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 ShidToPatioIntMultiplyTests { + @Test + public void canGenerateCodeForIntMultiply(Snapshotter snapshotter) throws IOException { + var shid = Shid.intMultiply(); + 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)); + } +} |
