aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2025-03-03 18:37:40 +0000
committerMichael Williamson <mike@zwobble.org>2025-03-03 18:37:40 +0000
commit88fb47120e293fad7cf3ecf5439a28136cb93eb2 (patch)
tree5dcad1e13634ebbd431a5227ff712abc3a2265d3 /src/test/java
parent806236a75e0cb2241d6a6e97b33da049e069f8b1 (diff)
Add Shid instruction to declare native type
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/shid/ShidSerializerTests.java12
-rw-r--r--src/test/java/org/shedlang/compiler/shid/instructions/Shid.java10
2 files changed, 22 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 3fc45b0b..89bfd1f7 100644
--- a/src/test/java/org/shedlang/compiler/shid/ShidSerializerTests.java
+++ b/src/test/java/org/shedlang/compiler/shid/ShidSerializerTests.java
@@ -66,6 +66,18 @@ public class ShidSerializerTests {
}
@Test
+ public void canSerializeDeclareNativeType() {
+ var instruction = Shid.declareNativeType(
+ Types.nativeType(NamespaceName.of("Example", "Project"), "Array")
+ );
+
+ var string = serialize(instruction);
+
+ assertThat(string, equalTo("""
+ (declare-native-type "Example/Project.Array")"""));
+ }
+
+ @Test
public void canSerializeDefineEffect() {
var instruction = Shid.defineEffect(
Effects.userDefined(NamespaceName.of("Example", "Project"), "State")
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 51f8ba00..10a020bd 100644
--- a/src/test/java/org/shedlang/compiler/shid/instructions/Shid.java
+++ b/src/test/java/org/shedlang/compiler/shid/instructions/Shid.java
@@ -2,6 +2,7 @@ package org.shedlang.compiler.shid.instructions;
import org.shedlang.compiler.sources.Sources;
import org.shedlang.compiler.types.NamespaceName;
+import org.shedlang.compiler.types.SimpleNativeType;
import org.shedlang.compiler.types.SimpleStructType;
import org.shedlang.compiler.types.UserDefinedEffect;
@@ -24,6 +25,15 @@ public class Shid {
return new ShidCall(positionalArgCount, namedArgNames, Sources.NULL);
}
+ public static ShidInstruction declareNativeType(
+ SimpleNativeType type
+ ) {
+ return new ShidDeclareNativeType(
+ type,
+ Sources.NULL
+ );
+ }
+
public static ShidInstruction defineEffect(UserDefinedEffect effect) {
return new ShidDefineEffect(effect, Sources.NULL);
}