Split packages
This commit is contained in:
35
test/integration_test.go
Normal file
35
test/integration_test.go
Normal file
@@ -0,0 +1,35 @@
|
||||
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(`
|
||||
functions:
|
||||
- - [add, f0, 1]
|
||||
- [call, +1]
|
||||
- [ltu, f0, 3]
|
||||
- [jmpt, -3]
|
||||
|
||||
- - [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))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user