basic instruction properties
This commit is contained in:
36
internal/inst/inst_test.go
Normal file
36
internal/inst/inst_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package inst
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestHaveInstructions(t *testing.T) {
|
||||
n := len(Instructions)
|
||||
t.Logf("number of instructions = %d", n)
|
||||
if n == 0 {
|
||||
t.Fatalf("no instructions")
|
||||
}
|
||||
}
|
||||
|
||||
func TestOpcodeDupes(t *testing.T) {
|
||||
count := map[string]int{}
|
||||
for _, i := range Instructions {
|
||||
count[i.Opcode]++
|
||||
}
|
||||
|
||||
for opcode, n := range count {
|
||||
if n > 1 {
|
||||
t.Errorf("opcode %s appears %d times", opcode, n)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestInstructionProperties(t *testing.T) {
|
||||
for _, i := range Instructions {
|
||||
if len(i.Opcode) == 0 {
|
||||
t.Errorf("empty opcode")
|
||||
}
|
||||
if len(i.Forms) == 0 {
|
||||
t.Errorf("instruction %s has no forms", i.Opcode)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user