This commit is contained in:
parent
89f375f4fc
commit
14bccadd0f
7 changed files with 54 additions and 16 deletions
|
@ -4,11 +4,19 @@ import (
|
|||
"testing"
|
||||
|
||||
"git.urbach.dev/cli/q/src/ssa"
|
||||
"git.urbach.dev/go/assert"
|
||||
)
|
||||
|
||||
func TestBlock(t *testing.T) {
|
||||
block := &ssa.Block{}
|
||||
block.Append(ssa.Instruction{Type: ssa.Int, Int: 1})
|
||||
block.Append(ssa.Instruction{Type: ssa.Int, Int: 2})
|
||||
block.Append(ssa.Instruction{Type: ssa.Add, Parameters: []ssa.Index{0, 1}})
|
||||
f := ssa.Function{}
|
||||
block := f.AddBlock()
|
||||
a := block.Append(ssa.Instruction{Type: ssa.Int, Int: 1})
|
||||
b := block.Append(ssa.Instruction{Type: ssa.Int, Int: 2})
|
||||
c := block.Append(ssa.Instruction{Type: ssa.Add, Args: []*ssa.Instruction{a, b}})
|
||||
assert.Equal(t, c.String(), "1 + 2")
|
||||
}
|
||||
|
||||
func TestInvalidInstruction(t *testing.T) {
|
||||
instr := ssa.Instruction{}
|
||||
assert.Equal(t, instr.String(), "")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue