github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/x/tools/go/gcimporter15/setname_test.go (about) 1 // Copyright 2016 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. 4 5 // +build go1.5 6 7 package gcimporter 8 9 import ( 10 "go/types" 11 "testing" 12 ) 13 14 func TestSetName(t *testing.T) { 15 pkg := types.NewPackage("path", "foo") 16 scope := pkg.Scope() 17 18 // verify setName 19 setName(pkg, "bar") 20 if name := pkg.Name(); name != "bar" { 21 t.Fatalf(`got package name %q; want "bar"`, name) 22 } 23 24 // verify no other fields are changed 25 if pkg.Path() != "path" || pkg.Scope() != scope || pkg.Complete() || pkg.Imports() != nil { 26 t.Fatalf("setName changed other fields") 27 } 28 }