2014-07-30 00:00:24 +00:00
|
|
|
package op
|
|
|
|
|
2020-03-10 16:34:40 +00:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"unsafe"
|
|
|
|
)
|
|
|
|
|
|
|
|
func ptrSizeByRuntimeArch() int {
|
|
|
|
return int(unsafe.Sizeof(uintptr(0)))
|
|
|
|
}
|
2014-07-30 00:00:24 +00:00
|
|
|
|
|
|
|
func TestExecuteStackProgram(t *testing.T) {
|
|
|
|
var (
|
2017-08-24 07:46:47 +00:00
|
|
|
instructions = []byte{byte(DW_OP_consts), 0x1c, byte(DW_OP_consts), 0x1c, byte(DW_OP_plus)}
|
2014-07-30 00:00:24 +00:00
|
|
|
expected = int64(56)
|
|
|
|
)
|
2020-03-10 16:34:40 +00:00
|
|
|
actual, _, err := ExecuteStackProgram(DwarfRegisters{}, instructions, ptrSizeByRuntimeArch())
|
2014-07-30 00:00:24 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if actual != expected {
|
|
|
|
t.Fatalf("actual %d != expected %d", actual, expected)
|
|
|
|
}
|
|
|
|
}
|