aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-07-23 11:13:22 +0100
committerMichael Williamson <mike@zwobble.org>2023-07-23 11:15:59 +0100
commit179af029a24147ffc09f8b165b7d812b135d3f2d (patch)
treea7e95ff18d542f1b99f3868514940fff7af1e795 /src/test/java
parent8e633a6c6f9ed28a24afb4c0ed7219d034850fd4 (diff)
Fix tests for int-add and string-add Patio code gen
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntAddTests.java4
-rw-r--r--src/test/java/org/shedlang/compiler/patio/PatioCodeGenStringAddTests.java28
2 files changed, 30 insertions, 2 deletions
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntAddTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntAddTests.java
index 328707a9..12016446 100644
--- a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntAddTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenIntAddTests.java
@@ -14,8 +14,8 @@ import static org.shedlang.compiler.patio.PatioTesting.serialize;
@ExtendWith({SnapshotResolver.class})
public class PatioCodeGenIntAddTests {
@Test
- public void canGenerateCodeForStringAdd(Snapshotter snapshotter) throws IOException {
- var stackIr = Instructions.stringAdd();
+ public void canGenerateCodeForIntAdd(Snapshotter snapshotter) throws IOException {
+ var stackIr = Instructions.intAdd();
var context = PatioCodeGenContext.EMPTY
.temporaryPush(new PatioLocalRef("a"))
.temporaryPush(new PatioLocalRef("b"))
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenStringAddTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenStringAddTests.java
new file mode 100644
index 00000000..0ff8dade
--- /dev/null
+++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenStringAddTests.java
@@ -0,0 +1,28 @@
+package org.shedlang.compiler.patio;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.shedlang.compiler.patio.ast.operands.PatioLocalRef;
+import org.shedlang.compiler.stackir.instructions.Instructions;
+import org.shedlang.compiler.testing.snapshots.SnapshotResolver;
+import org.shedlang.compiler.testing.snapshots.Snapshotter;
+
+import java.io.IOException;
+
+import static org.shedlang.compiler.patio.PatioTesting.serialize;
+
+@ExtendWith({SnapshotResolver.class})
+public class PatioCodeGenStringAddTests {
+ @Test
+ public void canGenerateCodeForStringAdd(Snapshotter snapshotter) throws IOException {
+ var stackIr = Instructions.stringAdd();
+ var context = PatioCodeGenContext.EMPTY
+ .temporaryPush(new PatioLocalRef("a"))
+ .temporaryPush(new PatioLocalRef("b"))
+ .temporaryPush(new PatioLocalRef("c"));
+
+ var result = PatioCodeGen.generateInstruction(stackIr, context);
+
+ snapshotter.assertSnapshot(serialize(result));
+ }
+}