Files
avo/attr/attr_test.go
Koichi Shiraishi 15d6a9a17e attr,build: add TOPFRAME attribute (#98)
Go added the TOPFRAME attribute in https://golang.org/cl/169726/. This diff adds the new attribute to avo, and also updates handling of the REFLECTMETHOD attribute.
2019-09-26 21:11:50 -07:00

45 lines
974 B
Go

package attr
import "testing"
func TestAttributeAsm(t *testing.T) {
cases := []struct {
Attribute Attribute
Expect string
}{
{0, "0"},
{32768, "32768"},
{1, "NOPROF"},
{DUPOK, "DUPOK"},
{RODATA | NOSPLIT, "NOSPLIT|RODATA"},
{WRAPPER | 16384 | NOPTR, "NOPTR|WRAPPER|16384"},
{NEEDCTXT + NOFRAME + TLSBSS, "NEEDCTXT|TLSBSS|NOFRAME"},
{REFLECTMETHOD, "REFLECTMETHOD"},
{TOPFRAME, "TOPFRAME"},
}
for _, c := range cases {
got := c.Attribute.Asm()
if got != c.Expect {
t.Errorf("Attribute(%d).Asm() = %#v; expect %#v", c.Attribute, got, c.Expect)
}
}
}
func TestAttributeContainsTextFlags(t *testing.T) {
cases := []struct {
Attribute Attribute
Expect bool
}{
{0, false},
{32768, false},
{1, true},
{DUPOK, true},
{WRAPPER | 16384 | NOPTR, true},
}
for _, c := range cases {
if c.Attribute.ContainsTextFlags() != c.Expect {
t.Errorf("%s: ContainsTextFlags() expected %#v", c.Attribute.Asm(), c.Expect)
}
}
}