Move vm into subdir

This commit is contained in:
Ian Gulliver
2021-11-16 20:41:57 -10:00
parent cf33a52392
commit db33045391
10 changed files with 1 additions and 1 deletions

47
vm/state_test.go Normal file
View File

@@ -0,0 +1,47 @@
package vm
import "encoding/hex"
import "strings"
import "testing"
func TestFirst(t *testing.T) {
asm := [][]string{
[]string{
"0000020000000000010000000000000000000000000000000000000000000001",
"0000000100000000000000000000000000000001000000000000000000000000",
"0000030100000000010000000000000000000000000000000000000000000003",
"000004010000000000000000fffffffffffffffd000000000000000000000000",
},
[]string{
"0000020000000000020000000000000000000000000000000000000000000001",
},
}
functionByteCode := [][]byte{}
for _, fnc := range asm {
fncString := strings.Join(fnc, "")
byteCode, err := hex.DecodeString(fncString)
if err != nil {
t.Fatal(err)
}
functionByteCode = append(functionByteCode, byteCode)
}
state, err := NewStateFromByteCode(functionByteCode)
if err != nil {
t.Fatal(err)
}
state.Execute()
if state.err != nil {
t.Fatal(state)
}
if state.globalMemory.mustReadUnsigned(0) != 3 {
t.Fatal(state.globalMemory.mustReadUnsigned(0))
}
}