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.
13 var importablePackages
= [...]string{
45 "database/sql/driver",
84 "image/color/palette",
103 "net/http/cookiejar",
139 "text/template/parse",
146 func TestInstallationImporter(t
*testing
.T
) {
147 // This test relies on gccgo being around, which it most likely will be if we
148 // were compiled with gccgo.
149 if runtime
.Compiler
!= "gccgo" {
150 t
.Skip("This test needs gccgo")
153 // Even when we have gccgo, this doesn't work while building
155 t
.Skip("gccgo is not necessarily available")
157 var inst GccgoInstallation
158 err
:= inst
.InitFromDriver("gccgo")
162 imp
:= inst
.GetImporter(nil, nil)
164 // Ensure we don't regress the number of packages we can parse. First import
165 // all packages into the same map and then each individually.
166 pkgMap
:= make(map[string]*types
.Package
)
167 for _
, pkg
:= range importablePackages
{
168 _
, err
= imp(pkgMap
, pkg
, ".", nil)
174 for _
, pkg
:= range importablePackages
{
175 _
, err
= imp(make(map[string]*types
.Package
), pkg
, ".", nil)
181 // Test for certain specific entities in the imported data.
182 for _
, test
:= range [...]importerTest
{
183 {pkgpath
: "io", name
: "Reader", want
: "type Reader interface{Read(p []uint8) (n int, err error)}"},
184 {pkgpath
: "io", name
: "ReadWriter", want
: "type ReadWriter interface{Reader; Writer}"},
185 {pkgpath
: "math", name
: "Pi", want
: "const Pi untyped float"},
186 {pkgpath
: "math", name
: "Sin", want
: "func Sin(x float64) float64"},
187 {pkgpath
: "sort", name
: "Ints", want
: "func Ints(a []int)"},
188 {pkgpath
: "unsafe", name
: "Pointer", want
: "type Pointer unsafe.Pointer"},
190 runImporterTest(t
, imp
, nil, &test
)