aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2023-06-11 23:02:41 +0100
committerMichael Williamson <mike@zwobble.org>2023-06-11 23:02:41 +0100
commit5564950ec34d3be47b9e39d3c8cdf58c0b38af1d (patch)
tree0965a71e3f41ab532d4dd04a29a5e47d7a28238a /src/test/java
parent594488a5ac0edef9074ed8957c65137cee453e37 (diff)
Compile push-unit instruction to LLVM IR
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/shedlang/compiler/backends/llvm/LlvmCompilerPushUnitTests.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/backends/llvm/LlvmCompilerPushUnitTests.java b/src/test/java/org/shedlang/compiler/backends/llvm/LlvmCompilerPushUnitTests.java
new file mode 100644
index 00000000..7a3da398
--- /dev/null
+++ b/src/test/java/org/shedlang/compiler/backends/llvm/LlvmCompilerPushUnitTests.java
@@ -0,0 +1,21 @@
+package org.shedlang.compiler.backends.llvm;
+
+import org.junit.jupiter.api.Test;
+import org.shedlang.compiler.stackir.instructions.Instructions;
+
+import static org.shedlang.compiler.backends.llvm.ir.ast.LlvmIrMatchers.isLlvmOperandInt;
+import static org.zwobble.precisely.AssertThat.assertThat;
+import static org.zwobble.precisely.Matchers.isSequence;
+
+public class LlvmCompilerPushUnitTests {
+ @Test
+ public void pushUnitIsCompiledToOperandInStack() {
+ var instruction = Instructions.pushUnit();
+ var context = LlvmCompilerContext.EMPTY;
+
+ var result = LlvmCompiler.compileInstruction(instruction, context);
+
+ assertThat(result.instructions(), isSequence());
+ assertThat(result.stack(), isSequence(isLlvmOperandInt(0)));
+ }
+}