Skip to content

Commit

Permalink
add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
katsyoshi committed Aug 10, 2024
1 parent 872a780 commit 3b23c2e
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions test/vaporware/compiler/test_assembler.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
require "vaporware"
require "test/unit"
require "tempfile"

class Vaporware::Compiler::Assembler::ELFTest < Test::Unit::TestCase
def reference_binary = ""

def test_to_elf
input_file = Tempfile.open(["amd64.s"])
input_file.puts <<~AMD64ASM
.intel_syntax noprefix
.globl main
main:
push rbp
mov rbp, rsp
sub rsp, 0
push 1
push 2
pop rdi
pop rax
add rax, rdi
push rax
push 3
pop rdi
pop rax
imul rax, rdi
push rax
push 5
push 4
pop rdi
pop rax
sub rax, rdi
push rax
pop rdi
pop rax
cqo
idiv rdi
push rax
mov rsp, rbp
pop rbp
ret
AMD64ASM
input = input_file.path

assembler = Vaporware::Compiler::Assembler.new(input:, output: "amd64.o")
assembler.to_elf
binding.irb
end
end

0 comments on commit 3b23c2e

Please sign in to comment.