From 04dff356a4323d2b22f0916ffe6931a31f75bb77 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 11 Jun 2023 23:04:18 +0100 Subject: Compile push-int instruction to LLVM IR --- .../backends/llvm/LlvmCompilerPushIntTests.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/test/java/org/shedlang/compiler/backends/llvm/LlvmCompilerPushIntTests.java (limited to 'src/test/java') diff --git a/src/test/java/org/shedlang/compiler/backends/llvm/LlvmCompilerPushIntTests.java b/src/test/java/org/shedlang/compiler/backends/llvm/LlvmCompilerPushIntTests.java new file mode 100644 index 00000000..983a1661 --- /dev/null +++ b/src/test/java/org/shedlang/compiler/backends/llvm/LlvmCompilerPushIntTests.java @@ -0,0 +1,23 @@ +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 LlvmCompilerPushIntTests { + // TODO: handle larger ints + + @Test + public void pushIntIsCompiledToOperandInStack() { + var instruction = Instructions.pushInt(42); + var context = LlvmCompilerContext.EMPTY; + + var result = LlvmCompiler.compileInstruction(instruction, context); + + assertThat(result.instructions(), isSequence()); + assertThat(result.stack(), isSequence(isLlvmOperandInt(42))); + } +} -- cgit v1.2.3