1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
package pass
import (
"testing"
"github.com/mmcloughlin/addchain/acc/ir"
)
func TestCheckDanglingInputsError(t *testing.T) {
// Shift instruction followed by a reference to an intermediate result.
p := &ir.Program{
Instructions: []*ir.Instruction{
{
Output: ir.Index(3),
Op: ir.Shift{
X: ir.Index(0),
S: 3,
},
},
{
Output: ir.Index(4),
Op: ir.Add{
X: ir.Index(1),
Y: ir.Index(3),
},
},
},
}
err := CheckDanglingInputs(p)
if err == nil {
t.Fatal("expected error")
}
}
|