package venus.assembler

import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
import venus.simulator.Simulator

class LinkerTest {
    @Test
    fun linkOneFile() {
        val prog = Assembler.assemble("""
        start:
        addi x8 x8 1
        addi x9 x0 2
        beq x8 x9 skip
        jal x0 start
        skip:
        """)
        val linked = Linker.link(listOf(prog))
        var sim = Simulator(linked.dump())
        sim.run()
        assertEquals(2, sim.state.getReg(8))
    }
}
package venus.assembler

import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
import venus.simulator.Simulator

class LinkerTest {
    @Test
    fun linkOneFile() {
        val prog = Assembler.assemble("""
        start:
        addi x8 x8 1
        addi x9 x0 2
        beq x8 x9 skip
        jal x0 start
        skip:
        """)
        val linked = Linker.link(listOf(prog))
        var sim = Simulator(linked.dump())
        sim.run()
        assertEquals(2, sim.state.getReg(8))
    }

    @Test
    fun linkTwoFiles() {
        val prog1 = Assembler.assemble("""
        foo:
            jal x0 bar
            addi x8 x0 8
        """)
        val prog2 = Assembler.assemble("""
        bar:
            addi x8 x8 1
        """)
        val linked = Linker.link(listOf(prog1, prog2))
        var sim = Simulator(linked.dump())
        sim.run()
        assertEquals(1, sim.state.getReg(8))
    }
}
Add linker test for two files
Add linker test for two files

kvakil/venus,kvakil/venus,kvakil/venus