fix signature size/alignment computation

This commit is contained in:
Michael McLoughlin
2018-12-19 13:08:56 -08:00
parent 33f5561d91
commit 48a84b6b13
3 changed files with 42 additions and 16 deletions

View File

@@ -93,3 +93,23 @@ func TypesTuplesEqual(a, b *types.Tuple) bool {
func TypesVarsEqual(a, b *types.Var) bool {
return a.Name() == b.Name() && types.Identical(a.Type(), b.Type())
}
func TestSignatureSizes(t *testing.T) {
cases := []struct {
Expr string
ArgSize int
}{
{"func()", 0},
{"func(uint64) uint64", 16},
{"func([7]byte) byte", 9},
}
for _, c := range cases {
s, err := ParseSignature(c.Expr)
if err != nil {
t.Fatal(err)
}
if s.Bytes() != c.ArgSize {
t.Errorf("%s: size %d expected %d", s, s.Bytes(), c.ArgSize)
}
}
}