Run Format

Source file src/go/internal/gccgoimporter/gccgoinstallation_test.go

Documentation: go/internal/gccgoimporter

  // Copyright 2013 The Go Authors. All rights reserved.
  // Use of this source code is governed by a BSD-style
  // license that can be found in the LICENSE file.
  package gccgoimporter
  import (
  var importablePackages = [...]string{
  func TestInstallationImporter(t *testing.T) {
  	// This test relies on gccgo being around, which it most likely will be if we
  	// were compiled with gccgo.
  	if runtime.Compiler != "gccgo" {
  		t.Skip("This test needs gccgo")
  	var inst GccgoInstallation
  	err := inst.InitFromDriver("gccgo")
  	if err != nil {
  	imp := inst.GetImporter(nil, nil)
  	// Ensure we don't regress the number of packages we can parse. First import
  	// all packages into the same map and then each individually.
  	pkgMap := make(map[string]*types.Package)
  	for _, pkg := range importablePackages {
  		_, err = imp(pkgMap, pkg, ".", nil)
  		if err != nil {
  	for _, pkg := range importablePackages {
  		_, err = imp(make(map[string]*types.Package), pkg, ".", nil)
  		if err != nil {
  	// Test for certain specific entities in the imported data.
  	for _, test := range [...]importerTest{
  		{pkgpath: "io", name: "Reader", want: "type Reader interface{Read(p []uint8) (n int, err error)}"},
  		{pkgpath: "io", name: "ReadWriter", want: "type ReadWriter interface{Reader; Writer}"},
  		{pkgpath: "math", name: "Pi", want: "const Pi untyped float"},
  		{pkgpath: "math", name: "Sin", want: "func Sin(x float64) float64"},
  		{pkgpath: "sort", name: "Ints", want: "func Ints(a []int)"},
  		{pkgpath: "unsafe", name: "Pointer", want: "type Pointer unsafe.Pointer"},
  	} {
  		runImporterTest(t, imp, nil, &test)

View as plain text