aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-03-21 15:36:58 +0000
committerMichael Williamson <mike@zwobble.org>2026-03-21 15:36:58 +0000
commit7785c220bcef000aedfbe2b9c95a32272786f370 (patch)
tree6d57a74a1c129a6eb95234ae6d88690d19d95702 /src/test/java
parent8db8026f1ce7d31eab18b02dab5ed54a512dcb48 (diff)
Serialize Patio operands to Protobuf
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/patio/protobuf/PatioToProtobufTests.java80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/patio/protobuf/PatioToProtobufTests.java b/src/test/java/org/shedlang/compiler/patio/protobuf/PatioToProtobufTests.java
index 35ec4221..03ded426 100644
--- a/src/test/java/org/shedlang/compiler/patio/protobuf/PatioToProtobufTests.java
+++ b/src/test/java/org/shedlang/compiler/patio/protobuf/PatioToProtobufTests.java
@@ -2,6 +2,7 @@ package org.shedlang.compiler.patio.protobuf;
import org.junit.jupiter.api.Test;
import org.shedlang.compiler.patio.PatioFunctionDeclaration;
+import org.shedlang.compiler.patio.PatioTesting;
import org.shedlang.compiler.patio.PatioVisibility;
import org.shedlang.compiler.patio.instructions.Patio;
import org.shedlang.compiler.patio.types.PatioDataLayouts;
@@ -96,6 +97,85 @@ public class PatioToProtobufTests {
assertThat(deserializedElement, equalTo(element));
}
+ // == Operands ==
+
+ @Test
+ public void canSerializeBoolConst() {
+ var operand = Patio.boolConst(true);
+
+ var deserializedOperand = PatioToProtobuf.deserializeOperand(
+ PatioToProtobuf.serializeOperand(operand)
+ );
+
+ assertThat(deserializedOperand, equalTo(operand));
+ }
+
+ @Test
+ public void canSerializeByteConst() {
+ var operand = Patio.byteConst((byte) 42);
+
+ var deserializedOperand = PatioToProtobuf.deserializeOperand(
+ PatioToProtobuf.serializeOperand(operand)
+ );
+
+ assertThat(deserializedOperand, equalTo(operand));
+ }
+
+ @Test
+ public void canSerializeDataPtrConst() {
+ var operand = Patio.dataPtrConst("x");
+
+ var deserializedOperand = PatioToProtobuf.deserializeOperand(
+ PatioToProtobuf.serializeOperand(operand)
+ );
+
+ assertThat(deserializedOperand, equalTo(operand));
+ }
+
+ @Test
+ public void canSerializeFunctionPtrConst() {
+ var operand = Patio.functionPtrConst("x");
+
+ var deserializedOperand = PatioToProtobuf.deserializeOperand(
+ PatioToProtobuf.serializeOperand(operand)
+ );
+
+ assertThat(deserializedOperand, equalTo(operand));
+ }
+
+ @Test
+ public void canSerializeIntConst() {
+ var operand = Patio.intConst(42);
+
+ var deserializedOperand = PatioToProtobuf.deserializeOperand(
+ PatioToProtobuf.serializeOperand(operand)
+ );
+
+ assertThat(deserializedOperand, equalTo(operand));
+ }
+
+ @Test
+ public void canSerializeInt32Const() {
+ var operand = Patio.int32Const(42);
+
+ var deserializedOperand = PatioToProtobuf.deserializeOperand(
+ PatioToProtobuf.serializeOperand(operand)
+ );
+
+ assertThat(deserializedOperand, equalTo(operand));
+ }
+
+ @Test
+ public void canSerializeLocalRef() {
+ var operand = Patio.localRef("x");
+
+ var deserializedOperand = PatioToProtobuf.deserializeOperand(
+ PatioToProtobuf.serializeOperand(operand)
+ );
+
+ assertThat(deserializedOperand, equalTo(operand));
+ }
+
// == Data ptr values ==
@Test