wip: adding instruction inputs and outputs

This commit is contained in:
Michael McLoughlin
2018-12-02 17:57:12 -08:00
parent f18271ada5
commit 82b31fa0da
15 changed files with 18157 additions and 7650 deletions

View File

@@ -32,6 +32,26 @@ func TestOpcodeDupes(t *testing.T) {
}
}
func TestFormDupes(t *testing.T) {
for _, i := range inst.Instructions {
if HasFormDupe(i) {
t.Errorf("%s has duplicate forms", i.Opcode)
}
}
}
func HasFormDupe(i inst.Instruction) bool {
n := len(i.Forms)
for a := 0; a < n; a++ {
for b := a + 1; b < n; b++ {
if reflect.DeepEqual(i.Forms[a], i.Forms[b]) {
return true
}
}
}
return false
}
func TestInstructionProperties(t *testing.T) {
for _, i := range inst.Instructions {
if len(i.Opcode) == 0 {
@@ -43,6 +63,9 @@ func TestInstructionProperties(t *testing.T) {
if len(i.Arities()) == 0 {
t.Errorf("instruction %s has empty arities list", i.Opcode)
}
if i.IsNiladic() && len(i.Forms) != 1 {
t.Errorf("%s breaks our expectation that niladic functions have one form", i.Opcode)
}
}
}