diff options
| author | Michael Williamson <mike@zwobble.org> | 2025-03-03 18:40:55 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2025-03-03 18:40:55 +0000 |
| commit | c6005eba5727e711516ccc17fa64cf153a602260 (patch) | |
| tree | 12975dd216dd33258f61799c2702c144a1d4a19a /src/test/java | |
| parent | 88fb47120e293fad7cf3ecf5439a28136cb93eb2 (diff) | |
Compile typed native type declaration node into Shid
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/shid/ShidCodeGenNativeTypeDeclarationTests.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/shid/ShidCodeGenNativeTypeDeclarationTests.java b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenNativeTypeDeclarationTests.java new file mode 100644 index 00000000..6a4070c5 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/shid/ShidCodeGenNativeTypeDeclarationTests.java @@ -0,0 +1,33 @@ +package org.shedlang.compiler.shid; + +import org.junit.jupiter.api.Test; +import org.shedlang.compiler.ast.typed.TypedNativeTypeDeclarationNode; +import org.shedlang.compiler.shid.instructions.ShidDeclareNativeType; +import org.shedlang.compiler.types.NamespaceName; +import org.shedlang.compiler.types.Types; + +import static org.shedlang.compiler.shid.instructions.ShidMatchers.isShidLocalStore; +import static org.zwobble.precisely.AssertThat.assertThat; +import static org.zwobble.precisely.Matchers.*; + +public class ShidCodeGenNativeTypeDeclarationTests { + @Test + public void nativeTypeDeclarationIsCompiledToDeclareNativeTypeInstruction() { + var nativeType = Types.nativeType(NamespaceName.of("Example", "Project"), "Array"); + var node = TypedNativeTypeDeclarationNode.builder() + .withType(nativeType) + .build(); + var context = ShidCodeGen.Context.EMPTY + .addShedVal("Array"); + + var result = ShidCodeGen.compileNamespaceStatement(node, context); + + assertThat(result.instructions(), isSequence( + instanceOf( + ShidDeclareNativeType.class, + has("type", x -> x.type(), equalTo(nativeType)) + ), + isShidLocalStore("Array__0") + )); + } +} |
