From bec73ca7a18f84c27c9e2af8b0720b54b8ef1b58 Mon Sep 17 00:00:00 2001 From: Michael McLoughlin Date: Sat, 24 Nov 2018 14:08:55 -0800 Subject: [PATCH] basic instruction properties --- internal/inst/inst_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 internal/inst/inst_test.go diff --git a/internal/inst/inst_test.go b/internal/inst/inst_test.go new file mode 100644 index 0000000..75a8f00 --- /dev/null +++ b/internal/inst/inst_test.go @@ -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) + } + } + +}