aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2024-12-22 11:05:15 +0000
committerMichael Williamson <mike@zwobble.org>2024-12-22 11:05:15 +0000
commit1397d18e897e98ede05e8bbc7b394c0469fb887a (patch)
tree6ed2e41c31ba7b6565b346c187fa7d94c92a2213 /src/test/java
parent1a1f26b2abdd3bd9edfebd55c2559f1b77a8f947 (diff)
Implement Patio codegen for method store and load
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/backends/llvm/Amd64ExampleTests.java1
-rw-r--r--src/test/java/org/shedlang/compiler/backends/llvm/I686ExampleTests.java1
-rw-r--r--src/test/java/org/shedlang/compiler/backends/wasm/Wasm32ExampleTests.java1
-rw-r--r--src/test/java/org/shedlang/compiler/backends/wasm/Wasm64ExampleTests.java1
-rw-r--r--src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioMethodLoadTests.java32
-rw-r--r--src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioMethodStoreTests.java33
6 files changed, 65 insertions, 4 deletions
diff --git a/src/test/java/org/shedlang/compiler/backends/llvm/Amd64ExampleTests.java b/src/test/java/org/shedlang/compiler/backends/llvm/Amd64ExampleTests.java
index bd754c3f..2fbe9f4b 100644
--- a/src/test/java/org/shedlang/compiler/backends/llvm/Amd64ExampleTests.java
+++ b/src/test/java/org/shedlang/compiler/backends/llvm/Amd64ExampleTests.java
@@ -23,7 +23,6 @@ public class Amd64ExampleTests extends ExampleTests {
}
private static final Set<String> DISABLED = Set.of(
- "35-struct-methods"
);
@Override
diff --git a/src/test/java/org/shedlang/compiler/backends/llvm/I686ExampleTests.java b/src/test/java/org/shedlang/compiler/backends/llvm/I686ExampleTests.java
index 9de1ff27..07240512 100644
--- a/src/test/java/org/shedlang/compiler/backends/llvm/I686ExampleTests.java
+++ b/src/test/java/org/shedlang/compiler/backends/llvm/I686ExampleTests.java
@@ -23,7 +23,6 @@ public class I686ExampleTests extends ExampleTests {
}
private static final Set<String> DISABLED = Set.of(
- "35-struct-methods"
);
@Override
diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/Wasm32ExampleTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/Wasm32ExampleTests.java
index 1e56b989..7b0ab151 100644
--- a/src/test/java/org/shedlang/compiler/backends/wasm/Wasm32ExampleTests.java
+++ b/src/test/java/org/shedlang/compiler/backends/wasm/Wasm32ExampleTests.java
@@ -23,7 +23,6 @@ public class Wasm32ExampleTests extends ExampleTests {
}
private static final Set<String> DISABLED = Set.of(
- "35-struct-methods"
);
@Override
diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/Wasm64ExampleTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/Wasm64ExampleTests.java
index 972da7b7..71d5f17b 100644
--- a/src/test/java/org/shedlang/compiler/backends/wasm/Wasm64ExampleTests.java
+++ b/src/test/java/org/shedlang/compiler/backends/wasm/Wasm64ExampleTests.java
@@ -23,7 +23,6 @@ public class Wasm64ExampleTests extends ExampleTests {
}
private static final Set<String> DISABLED = Set.of(
- "35-struct-methods"
);
@Override
diff --git a/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioMethodLoadTests.java b/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioMethodLoadTests.java
new file mode 100644
index 00000000..6fc4abc2
--- /dev/null
+++ b/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioMethodLoadTests.java
@@ -0,0 +1,32 @@
+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 org.shedlang.compiler.typechecker.TypeCheckerContext;
+import org.shedlang.compiler.types.NamespaceName;
+import org.shedlang.compiler.types.Types;
+
+import java.io.IOException;
+
+import static org.shedlang.compiler.shidtopatio.ShidToPatioTesting.serialize;
+
+@ExtendWith({SnapshotResolver.class})
+public class ShidToPatioMethodLoadTests {
+ @Test
+ public void canGenerateCodeForMethodLoad(Snapshotter snapshotter) throws IOException {
+ var namespaceName = NamespaceName.of("Example", "Project");
+ var structType = Types.struct(namespaceName, "User");
+ var shidInstruction = Shid.methodLoad(structType, "name");
+ var typeInfo = TypeCheckerContext.EMPTY.toTypeInfos();
+ var context = ShidToPatioContext.forTypeInfos(typeInfo)
+ .temporaryPush(new PatioLocalRef("a"));
+
+ var result = ShidToPatio.generateInstruction(shidInstruction, context);
+
+ snapshotter.assertSnapshot(serialize(result));
+ }
+}
diff --git a/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioMethodStoreTests.java b/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioMethodStoreTests.java
new file mode 100644
index 00000000..447a925a
--- /dev/null
+++ b/src/test/java/org/shedlang/compiler/shidtopatio/ShidToPatioMethodStoreTests.java
@@ -0,0 +1,33 @@
+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 org.shedlang.compiler.typechecker.TypeCheckerContext;
+import org.shedlang.compiler.types.NamespaceName;
+import org.shedlang.compiler.types.Types;
+
+import java.io.IOException;
+
+import static org.shedlang.compiler.shidtopatio.ShidToPatioTesting.serialize;
+
+@ExtendWith({SnapshotResolver.class})
+public class ShidToPatioMethodStoreTests {
+ @Test
+ public void canGenerateCodeForMethodStore(Snapshotter snapshotter) throws IOException {
+ var namespaceName = NamespaceName.of("Example", "Project");
+ var structType = Types.struct(namespaceName, "User");
+ var shidInstruction = Shid.methodStore(structType, "name");
+ var typeInfo = TypeCheckerContext.EMPTY.toTypeInfos();
+ var context = ShidToPatioContext.forTypeInfos(typeInfo)
+ .temporaryPush(new PatioLocalRef("a"))
+ .temporaryPush(new PatioLocalRef("b"));
+
+ var result = ShidToPatio.generateInstruction(shidInstruction, context);
+
+ snapshotter.assertSnapshot(serialize(result));
+ }
+}