diff options
| author | Michael Williamson <mike@zwobble.org> | 2023-07-20 16:42:22 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2023-07-20 16:42:22 +0100 |
| commit | 48217d912243feadde179709a61b1741941606f3 (patch) | |
| tree | de5dc38e990549ef36f9e06db3d61d97540df973 /src/test/java | |
| parent | ef3b54474640a245d7e2f92ee56604246312ef29 (diff) | |
Test PatioCodeGen.generateNamespace()
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceTests.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceTests.java b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceTests.java new file mode 100644 index 00000000..a19d3113 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/patio/PatioCodeGenNamespaceTests.java @@ -0,0 +1,41 @@ +package org.shedlang.compiler.patio; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.shedlang.compiler.ast.typed.FreeVariables; +import org.shedlang.compiler.sources.Sources; +import org.shedlang.compiler.stackir.instructions.DefineFunctionInstruction; +import org.shedlang.compiler.stackir.instructions.Instruction; +import org.shedlang.compiler.stackir.instructions.Instructions; +import org.shedlang.compiler.testing.snapshots.SnapshotResolver; +import org.shedlang.compiler.testing.snapshots.Snapshotter; + +import java.io.IOException; +import java.util.List; + +import static org.shedlang.compiler.patio.PatioTesting.serializeCompilationUnit; + +@ExtendWith({SnapshotResolver.class}) +public class PatioCodeGenNamespaceTests { + @Test + public void canDefineNamespace(Snapshotter snapshotter) throws IOException { + var instruction = new DefineFunctionInstruction( + "f", + List.of(), + List.of(), + FreeVariables.empty(), + List.of( + Instructions.pushUnit(), + Instructions.return_() + ), + Sources.NULL + ); + var instructions = List.<Instruction>of(instruction); + var context = PatioCodeGenContext.EMPTY; + + var result = PatioCodeGen.generateNamespace(instructions, context); + + snapshotter.assertSnapshot(serializeCompilationUnit(result)); + } + +} |
