diff options
Diffstat (limited to 'src/cmd/link/internal/ld/deadcode_test.go')
| -rw-r--r-- | src/cmd/link/internal/ld/deadcode_test.go | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/cmd/link/internal/ld/deadcode_test.go b/src/cmd/link/internal/ld/deadcode_test.go index 573bff3c85..633a0d0bfb 100644 --- a/src/cmd/link/internal/ld/deadcode_test.go +++ b/src/cmd/link/internal/ld/deadcode_test.go @@ -19,14 +19,16 @@ func TestDeadcode(t *testing.T) { tests := []struct { src string - pos, neg string // positive and negative patterns + pos, neg []string // positive and negative patterns }{ - {"reflectcall", "", "main.T.M"}, - {"typedesc", "", "type:main.T"}, - {"ifacemethod", "", "main.T.M"}, - {"ifacemethod2", "main.T.M", ""}, - {"ifacemethod3", "main.S.M", ""}, - {"ifacemethod4", "", "main.T.M"}, + {"reflectcall", nil, []string{"main.T.M"}}, + {"typedesc", nil, []string{"type:main.T"}}, + {"ifacemethod", nil, []string{"main.T.M"}}, + {"ifacemethod2", []string{"main.T.M"}, nil}, + {"ifacemethod3", []string{"main.S.M"}, nil}, + {"ifacemethod4", nil, []string{"main.T.M"}}, + {"globalmap", []string{"main.small", "main.effect"}, + []string{"main.large"}}, } for _, test := range tests { test := test @@ -39,11 +41,15 @@ func TestDeadcode(t *testing.T) { if err != nil { t.Fatalf("%v: %v:\n%s", cmd.Args, err, out) } - if test.pos != "" && !bytes.Contains(out, []byte(test.pos+"\n")) { - t.Errorf("%s should be reachable. Output:\n%s", test.pos, out) + for _, pos := range test.pos { + if !bytes.Contains(out, []byte(pos+"\n")) { + t.Errorf("%s should be reachable. Output:\n%s", pos, out) + } } - if test.neg != "" && bytes.Contains(out, []byte(test.neg+"\n")) { - t.Errorf("%s should not be reachable. Output:\n%s", test.neg, out) + for _, neg := range test.neg { + if bytes.Contains(out, []byte(neg+"\n")) { + t.Errorf("%s should not be reachable. Output:\n%s", neg, out) + } } }) } |
