Split test utils, add opcode tests
This commit is contained in:
@@ -2,11 +2,8 @@ package test
|
||||
|
||||
import "testing"
|
||||
|
||||
import "github.com/firestuff/subcoding/asm"
|
||||
import "github.com/firestuff/subcoding/vm"
|
||||
|
||||
func TestLoop(t *testing.T) {
|
||||
prog, err := asm.AssembleString(`
|
||||
state := assembleAndExecute(t, `
|
||||
functions:
|
||||
- - [add, f0, 1]
|
||||
- [call, +1]
|
||||
@@ -15,21 +12,6 @@ functions:
|
||||
|
||||
- - [add, g0, 1]
|
||||
`)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
state, err := vm.NewState(prog)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = state.Execute()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if state.GlobalMemory().MustReadUnsigned(0) != 3 {
|
||||
t.Fatalf("Expected 3, found %d\n", state.GlobalMemory().MustReadUnsigned(0))
|
||||
}
|
||||
expectGlobalMemory(t, state, 0, 3)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user