From 99d37eb1f20e0c7fdcbc4bf42a25b94b33b5f793 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 21 Mar 2026 12:55:54 +0000 Subject: Serialize Patio types to protobuf --- .../patio/protobuf/PatioToProtobufTests.java | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) (limited to 'src/test/java') 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 f993fb68..30ee7f56 100644 --- a/src/test/java/org/shedlang/compiler/patio/protobuf/PatioToProtobufTests.java +++ b/src/test/java/org/shedlang/compiler/patio/protobuf/PatioToProtobufTests.java @@ -5,6 +5,7 @@ import org.shedlang.compiler.patio.PatioVisibility; import org.shedlang.compiler.patio.instructions.Patio; import org.shedlang.compiler.patio.types.PatioDataLayouts; import org.shedlang.compiler.patio.types.PatioDataValues; +import org.shedlang.compiler.patio.types.PatioTypes; import org.shedlang.compiler.sources.Sources; import java.util.List; @@ -135,6 +136,85 @@ public class PatioToProtobufTests { assertThat(deserializedIntValue, equalTo(intValue)); } + // == Types == + + @Test + public void canSerializeBoolType() { + var type = PatioTypes.BOOL; + + var deserializedType = PatioToProtobuf.deserializeType( + PatioToProtobuf.serializeType(type) + ); + + assertThat(deserializedType, equalTo(type)); + } + + @Test + public void canSerializeByteType() { + var type = PatioTypes.BYTE; + + var deserializedType = PatioToProtobuf.deserializeType( + PatioToProtobuf.serializeType(type) + ); + + assertThat(deserializedType, equalTo(type)); + } + + @Test + public void canSerializeDataPtrType() { + var type = PatioTypes.DATA_PTR; + + var deserializedType = PatioToProtobuf.deserializeType( + PatioToProtobuf.serializeType(type) + ); + + assertThat(deserializedType, equalTo(type)); + } + + @Test + public void canSerializeFunctionPtrType() { + var type = PatioTypes.FUNCTION_PTR; + + var deserializedType = PatioToProtobuf.deserializeType( + PatioToProtobuf.serializeType(type) + ); + + assertThat(deserializedType, equalTo(type)); + } + + @Test + public void canSerializeIntType() { + var type = PatioTypes.INT; + + var deserializedType = PatioToProtobuf.deserializeType( + PatioToProtobuf.serializeType(type) + ); + + assertThat(deserializedType, equalTo(type)); + } + + @Test + public void canSerializeInt32Type() { + var type = PatioTypes.INT32; + + var deserializedType = PatioToProtobuf.deserializeType( + PatioToProtobuf.serializeType(type) + ); + + assertThat(deserializedType, equalTo(type)); + } + + @Test + public void canSerializeVoidType() { + var type = PatioTypes.VOID; + + var deserializedType = PatioToProtobuf.deserializeType( + PatioToProtobuf.serializeType(type) + ); + + assertThat(deserializedType, equalTo(type)); + } + // == Data layouts == @Test -- cgit v1.2.3