1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Except for this comment, this file is a verbatim copy of the file
6 // with the same name in $GOROOT/src/go/internal/gccgoimporter.
15 // importablePackages is a list of packages that we verify that we can
16 // import. This should be all standard library packages in all relevant
17 // versions of gccgo. Note that since gccgo follows a different release
18 // cycle, and since different systems have different versions installed,
19 // we can't use the last-two-versions rule of the gc toolchain.
20 var importablePackages = [...]string{
52 "database/sql/driver",
66 // "encoding", // Added in GCC 4.9.
78 // "go/format", // Added in GCC 4.8.
91 // "image/color/palette", // Added in GCC 4.9.
110 // "net/http/cookiejar", // Added in GCC 4.8.
146 "text/template/parse",
153 func TestInstallationImporter(t *testing.T) {
154 // This test relies on gccgo being around.
157 t.Skip("This test needs gccgo")
160 var inst GccgoInstallation
161 err := inst.InitFromDriver(gpath)
165 imp := inst.GetImporter(nil, nil)
167 // Ensure we don't regress the number of packages we can parse. First import
168 // all packages into the same map and then each individually.
169 pkgMap := make(map[string]*types.Package)
170 for _, pkg := range importablePackages {
171 _, err = imp(pkgMap, pkg, ".", nil)
177 for _, pkg := range importablePackages {
178 _, err = imp(make(map[string]*types.Package), pkg, ".", nil)
184 // Test for certain specific entities in the imported data.
185 for _, test := range [...]importerTest{
186 {pkgpath: "io", name: "Reader", want: "type Reader interface{Read(p []byte) (n int, err error)}"},
187 {pkgpath: "io", name: "ReadWriter", want: "type ReadWriter interface{Reader; Writer}"},
188 {pkgpath: "math", name: "Pi", want: "const Pi untyped float"},
189 {pkgpath: "math", name: "Sin", want: "func Sin(x float64) float64"},
190 {pkgpath: "sort", name: "Ints", want: "func Ints(a []int)"},
191 {pkgpath: "unsafe", name: "Pointer", want: "type Pointer"},
193 runImporterTest(t, imp, nil, &test)