8d4dd2d2e1
This allows easier reuse of opcodes and in some cases allows to eliminate dependencies on the whole vm package, like in compiler that only needs opcodes and doesn't care about VM for any other purpose. And yes, they're opcodes because an instruction is a whole thing with operands, that's what context.Next() returns.
20 lines
346 B
Go
20 lines
346 B
Go
package opcode
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// Nothing more to test here, really.
|
|
func TestStringer(t *testing.T) {
|
|
tests := map[Opcode]string{
|
|
ADD: "ADD",
|
|
SUB: "SUB",
|
|
THROWIFNOT: "THROWIFNOT",
|
|
0xff: "Opcode(255)",
|
|
}
|
|
for o, s := range tests {
|
|
assert.Equal(t, s, o.String())
|
|
}
|
|
}
|