Commit 585a8767 authored by k8s-merge-robot's avatar k8s-merge-robot

Merge pull request #17853 from smarterclayton/non_go_idl

Auto commit by PR queue bot
parents 853af2d5 72df8bbf
...@@ -57,12 +57,12 @@ func (g *genGroup) GenerateType(c *generator.Context, t *types.Type, w io.Writer ...@@ -57,12 +57,12 @@ func (g *genGroup) GenerateType(c *generator.Context, t *types.Type, w io.Writer
"group": g.group, "group": g.group,
"Group": namer.IC(g.group), "Group": namer.IC(g.group),
"types": g.types, "types": g.types,
"Config": c.Universe.Get(types.Name{pkgUnversioned, "Config"}), "Config": c.Universe.Get(types.Name{Package: pkgUnversioned, Name: "Config"}),
"DefaultKubernetesUserAgent": c.Universe.Get(types.Name{pkgUnversioned, "DefaultKubernetesUserAgent"}), "DefaultKubernetesUserAgent": c.Universe.Get(types.Name{Package: pkgUnversioned, Name: "DefaultKubernetesUserAgent"}),
"RESTClient": c.Universe.Get(types.Name{pkgUnversioned, "RESTClient"}), "RESTClient": c.Universe.Get(types.Name{Package: pkgUnversioned, Name: "RESTClient"}),
"RESTClientFor": c.Universe.Get(types.Name{pkgUnversioned, "RESTClientFor"}), "RESTClientFor": c.Universe.Get(types.Name{Package: pkgUnversioned, Name: "RESTClientFor"}),
"latestGroup": c.Universe.Get(types.Name{pkgLatest, "Group"}), "latestGroup": c.Universe.Get(types.Name{Package: pkgLatest, Name: "Group"}),
"GroupOrDie": c.Universe.Get(types.Name{pkgLatest, "GroupOrDie"}), "GroupOrDie": c.Universe.Get(types.Name{Package: pkgLatest, Name: "GroupOrDie"}),
} }
sw.Do(groupInterfaceTemplate, m) sw.Do(groupInterfaceTemplate, m)
sw.Do(groupClientTemplate, m) sw.Do(groupClientTemplate, m)
......
...@@ -54,11 +54,11 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i ...@@ -54,11 +54,11 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
"type": t, "type": t,
"package": pkg, "package": pkg,
"Package": namer.IC(pkg), "Package": namer.IC(pkg),
"fieldSelector": c.Universe.Get(types.Name{"k8s.io/kubernetes/pkg/fields", "Selector"}), "fieldSelector": c.Universe.Get(types.Name{Package: "k8s.io/kubernetes/pkg/fields", Name: "Selector"}),
"labelSelector": c.Universe.Get(types.Name{"k8s.io/kubernetes/pkg/labels", "Selector"}), "labelSelector": c.Universe.Get(types.Name{Package: "k8s.io/kubernetes/pkg/labels", Name: "Selector"}),
"watchInterface": c.Universe.Get(types.Name{"k8s.io/kubernetes/pkg/watch", "Interface"}), "watchInterface": c.Universe.Get(types.Name{Package: "k8s.io/kubernetes/pkg/watch", Name: "Interface"}),
"apiDeleteOptions": c.Universe.Get(types.Name{"k8s.io/kubernetes/pkg/api", "DeleteOptions"}), "apiDeleteOptions": c.Universe.Get(types.Name{Package: "k8s.io/kubernetes/pkg/api", Name: "DeleteOptions"}),
"apiListOptions": c.Universe.Get(types.Name{"k8s.io/kubernetes/pkg/api", "ListOptions"}), "apiListOptions": c.Universe.Get(types.Name{Package: "k8s.io/kubernetes/pkg/api", Name: "ListOptions"}),
} }
sw.Do(namespacerTemplate, m) sw.Do(namespacerTemplate, m)
sw.Do(interfaceTemplate, m) sw.Do(interfaceTemplate, m)
......
...@@ -23,6 +23,10 @@ import ( ...@@ -23,6 +23,10 @@ import (
"k8s.io/kubernetes/cmd/libs/go2idl/types" "k8s.io/kubernetes/cmd/libs/go2idl/types"
) )
const (
GolangFileType = "golang"
)
// DefaultGen implements a do-nothing Generator. // DefaultGen implements a do-nothing Generator.
// //
// It can be used to implement static content files. // It can be used to implement static content files.
...@@ -45,6 +49,7 @@ func (d DefaultGen) PackageVars(*Context) []string { retur ...@@ -45,6 +49,7 @@ func (d DefaultGen) PackageVars(*Context) []string { retur
func (d DefaultGen) PackageConsts(*Context) []string { return []string{} } func (d DefaultGen) PackageConsts(*Context) []string { return []string{} }
func (d DefaultGen) GenerateType(*Context, *types.Type, io.Writer) error { return nil } func (d DefaultGen) GenerateType(*Context, *types.Type, io.Writer) error { return nil }
func (d DefaultGen) Filename() string { return d.OptionalName + ".go" } func (d DefaultGen) Filename() string { return d.OptionalName + ".go" }
func (d DefaultGen) FileType() string { return GolangFileType }
func (d DefaultGen) Init(c *Context, w io.Writer) error { func (d DefaultGen) Init(c *Context, w io.Writer) error {
_, err := w.Write(d.OptionalBody) _, err := w.Write(d.OptionalBody)
......
...@@ -44,17 +44,9 @@ func (c *Context) ExecutePackages(outDir string, packages Packages) error { ...@@ -44,17 +44,9 @@ func (c *Context) ExecutePackages(outDir string, packages Packages) error {
return nil return nil
} }
type file struct { type golangFileType struct{}
name string
packageName string
header []byte
imports map[string]struct{}
vars bytes.Buffer
consts bytes.Buffer
body bytes.Buffer
}
func (f *file) assembleToFile(pathname string) error { func (ft golangFileType) AssembleFile(f *File, pathname string) error {
log.Printf("Assembling file %q", pathname) log.Printf("Assembling file %q", pathname)
destFile, err := os.Create(pathname) destFile, err := os.Create(pathname)
if err != nil { if err != nil {
...@@ -64,7 +56,7 @@ func (f *file) assembleToFile(pathname string) error { ...@@ -64,7 +56,7 @@ func (f *file) assembleToFile(pathname string) error {
b := &bytes.Buffer{} b := &bytes.Buffer{}
et := NewErrorTracker(b) et := NewErrorTracker(b)
f.assemble(et) ft.assemble(et, f)
if et.Error() != nil { if et.Error() != nil {
return et.Error() return et.Error()
} }
...@@ -78,14 +70,14 @@ func (f *file) assembleToFile(pathname string) error { ...@@ -78,14 +70,14 @@ func (f *file) assembleToFile(pathname string) error {
} }
} }
func (f *file) assemble(w io.Writer) { func (ft golangFileType) assemble(w io.Writer, f *File) {
w.Write(f.header) w.Write(f.Header)
fmt.Fprintf(w, "package %v\n\n", f.packageName) fmt.Fprintf(w, "package %v\n\n", f.PackageName)
if len(f.imports) > 0 { if len(f.Imports) > 0 {
fmt.Fprint(w, "import (\n") fmt.Fprint(w, "import (\n")
// TODO: sort imports like goimports does. // TODO: sort imports like goimports does.
for i := range f.imports { for i := range f.Imports {
if strings.Contains(i, "\"") { if strings.Contains(i, "\"") {
// they included quotes, or are using the // they included quotes, or are using the
// `name "path/to/pkg"` format. // `name "path/to/pkg"` format.
...@@ -97,27 +89,27 @@ func (f *file) assemble(w io.Writer) { ...@@ -97,27 +89,27 @@ func (f *file) assemble(w io.Writer) {
fmt.Fprint(w, ")\n\n") fmt.Fprint(w, ")\n\n")
} }
if f.vars.Len() > 0 { if f.Vars.Len() > 0 {
fmt.Fprint(w, "var (\n") fmt.Fprint(w, "var (\n")
w.Write(f.vars.Bytes()) w.Write(f.Vars.Bytes())
fmt.Fprint(w, ")\n\n") fmt.Fprint(w, ")\n\n")
} }
if f.consts.Len() > 0 { if f.Consts.Len() > 0 {
fmt.Fprint(w, "const (\n") fmt.Fprint(w, "const (\n")
w.Write(f.consts.Bytes()) w.Write(f.Consts.Bytes())
fmt.Fprint(w, ")\n\n") fmt.Fprint(w, ")\n\n")
} }
w.Write(f.body.Bytes()) w.Write(f.Body.Bytes())
} }
// format should be one line only, and not end with \n. // format should be one line only, and not end with \n.
func addIndentHeaderComment(b *bytes.Buffer, format string, args ...interface{}) { func addIndentHeaderComment(b *bytes.Buffer, format string, args ...interface{}) {
if b.Len() > 0 { if b.Len() > 0 {
fmt.Fprintf(b, "\n\t// "+format+"\n", args...) fmt.Fprintf(b, "\n// "+format+"\n", args...)
} else { } else {
fmt.Fprintf(b, "\t// "+format+"\n", args...) fmt.Fprintf(b, "// "+format+"\n", args...)
} }
} }
...@@ -161,52 +153,66 @@ func (c *Context) ExecutePackage(outDir string, p Package) error { ...@@ -161,52 +153,66 @@ func (c *Context) ExecutePackage(outDir string, p Package) error {
// Filter out any types the *package* doesn't care about. // Filter out any types the *package* doesn't care about.
packageContext := c.filteredBy(p.Filter) packageContext := c.filteredBy(p.Filter)
os.MkdirAll(path, 0755) os.MkdirAll(path, 0755)
files := map[string]*file{} files := map[string]*File{}
for _, g := range p.Generators(packageContext) { for _, g := range p.Generators(packageContext) {
// Filter out types the *generator* doesn't care about. // Filter out types the *generator* doesn't care about.
genContext := packageContext.filteredBy(g.Filter) genContext := packageContext.filteredBy(g.Filter)
// Now add any extra name systems defined by this generator // Now add any extra name systems defined by this generator
genContext = genContext.addNameSystems(g.Namers(genContext)) genContext = genContext.addNameSystems(g.Namers(genContext))
fileType := g.FileType()
if len(fileType) == 0 {
return fmt.Errorf("generator %q must specify a file type", g.Name())
}
f := files[g.Filename()] f := files[g.Filename()]
if f == nil { if f == nil {
// This is the first generator to reference this file, so start it. // This is the first generator to reference this file, so start it.
f = &file{ f = &File{
name: g.Filename(), Name: g.Filename(),
packageName: p.Name(), FileType: fileType,
header: p.Header(g.Filename()), PackageName: p.Name(),
imports: map[string]struct{}{}, Header: p.Header(g.Filename()),
Imports: map[string]struct{}{},
}
files[f.Name] = f
} else {
if f.FileType != g.FileType() {
return fmt.Errorf("file %q already has type %q, but generator %q wants to use type %q", f.Name, f.FileType, g.Name(), g.FileType())
} }
files[f.name] = f
} }
if vars := g.PackageVars(genContext); len(vars) > 0 { if vars := g.PackageVars(genContext); len(vars) > 0 {
addIndentHeaderComment(&f.vars, "Package-wide variables from generator %q.", g.Name()) addIndentHeaderComment(&f.Vars, "Package-wide variables from generator %q.", g.Name())
for _, v := range vars { for _, v := range vars {
if _, err := fmt.Fprintf(&f.vars, "\t%s\n", v); err != nil { if _, err := fmt.Fprintf(&f.Vars, "%s\n", v); err != nil {
return err return err
} }
} }
} }
if consts := g.PackageVars(genContext); len(consts) > 0 { if consts := g.PackageVars(genContext); len(consts) > 0 {
addIndentHeaderComment(&f.consts, "Package-wide consts from generator %q.", g.Name()) addIndentHeaderComment(&f.Consts, "Package-wide consts from generator %q.", g.Name())
for _, v := range consts { for _, v := range consts {
if _, err := fmt.Fprintf(&f.consts, "\t%s\n", v); err != nil { if _, err := fmt.Fprintf(&f.Consts, "%s\n", v); err != nil {
return err return err
} }
} }
} }
if err := genContext.executeBody(&f.body, g); err != nil { if err := genContext.executeBody(&f.Body, g); err != nil {
return err return err
} }
if imports := g.Imports(genContext); len(imports) > 0 { if imports := g.Imports(genContext); len(imports) > 0 {
for _, i := range imports { for _, i := range imports {
f.imports[i] = struct{}{} f.Imports[i] = struct{}{}
} }
} }
} }
for _, f := range files { for _, f := range files {
if err := f.assembleToFile(filepath.Join(path, f.name)); err != nil { assembler, ok := c.FileTypes[f.FileType]
if !ok {
return fmt.Errorf("the file type %q registered for file %q does not exist in the context", f.FileType, f.Name)
}
if err := assembler.AssembleFile(f, filepath.Join(path, f.Name)); err != nil {
return err return err
} }
} }
......
...@@ -17,6 +17,7 @@ limitations under the License. ...@@ -17,6 +17,7 @@ limitations under the License.
package generator package generator
import ( import (
"bytes"
"io" "io"
"k8s.io/kubernetes/cmd/libs/go2idl/namer" "k8s.io/kubernetes/cmd/libs/go2idl/namer"
...@@ -48,6 +49,21 @@ type Package interface { ...@@ -48,6 +49,21 @@ type Package interface {
Generators(*Context) []Generator Generators(*Context) []Generator
} }
type File struct {
Name string
FileType string
PackageName string
Header []byte
Imports map[string]struct{}
Vars bytes.Buffer
Consts bytes.Buffer
Body bytes.Buffer
}
type FileType interface {
AssembleFile(f *File, path string) error
}
// Packages is a list of packages to generate. // Packages is a list of packages to generate.
type Packages []Package type Packages []Package
...@@ -120,6 +136,10 @@ type Generator interface { ...@@ -120,6 +136,10 @@ type Generator interface {
// TODO: provide per-file import tracking, removing the requirement // TODO: provide per-file import tracking, removing the requirement
// that generators coordinate.. // that generators coordinate..
Filename() string Filename() string
// A registered file type in the context to generate this file with. If
// the FileType is not found in the context, execution will stop.
FileType() string
} }
// Context is global context for individual generators to consume. // Context is global context for individual generators to consume.
...@@ -134,6 +154,10 @@ type Context struct { ...@@ -134,6 +154,10 @@ type Context struct {
// The canonical ordering of the types (will be filtered by both the // The canonical ordering of the types (will be filtered by both the
// Package's and Generator's Filter methods). // Package's and Generator's Filter methods).
Order []*types.Type Order []*types.Type
// A set of types this context can process. If this is empty or nil,
// the default "golang" filetype will be provided.
FileTypes map[string]FileType
} }
// NewContext generates a context from the given builder, naming systems, and // NewContext generates a context from the given builder, naming systems, and
...@@ -147,6 +171,9 @@ func NewContext(b *parser.Builder, nameSystems namer.NameSystems, canonicalOrder ...@@ -147,6 +171,9 @@ func NewContext(b *parser.Builder, nameSystems namer.NameSystems, canonicalOrder
c := &Context{ c := &Context{
Namers: namer.NameSystems{}, Namers: namer.NameSystems{},
Universe: u, Universe: u,
FileTypes: map[string]FileType{
GolangFileType: golangFileType{},
},
} }
for name, systemNamer := range nameSystems { for name, systemNamer := range nameSystems {
......
...@@ -116,6 +116,10 @@ func (s *SnippetWriter) Do(format string, args interface{}) *SnippetWriter { ...@@ -116,6 +116,10 @@ func (s *SnippetWriter) Do(format string, args interface{}) *SnippetWriter {
return s return s
} }
func (s *SnippetWriter) Out() io.Writer {
return s.w
}
// Error returns any encountered error. // Error returns any encountered error.
func (s *SnippetWriter) Error() error { func (s *SnippetWriter) Error() error {
return s.err return s.err
......
...@@ -27,26 +27,26 @@ func TestNameStrategy(t *testing.T) { ...@@ -27,26 +27,26 @@ func TestNameStrategy(t *testing.T) {
u := types.Universe{} u := types.Universe{}
// Add some types. // Add some types.
base := u.Get(types.Name{"foo/bar", "Baz"}) base := u.Get(types.Name{Package: "foo/bar", Name: "Baz"})
base.Kind = types.Struct base.Kind = types.Struct
tmp := u.Get(types.Name{"", "[]bar.Baz"}) tmp := u.Get(types.Name{Package: "", Name: "[]bar.Baz"})
tmp.Kind = types.Slice tmp.Kind = types.Slice
tmp.Elem = base tmp.Elem = base
tmp = u.Get(types.Name{"", "map[string]bar.Baz"}) tmp = u.Get(types.Name{Package: "", Name: "map[string]bar.Baz"})
tmp.Kind = types.Map tmp.Kind = types.Map
tmp.Key = types.String tmp.Key = types.String
tmp.Elem = base tmp.Elem = base
tmp = u.Get(types.Name{"foo/other", "Baz"}) tmp = u.Get(types.Name{Package: "foo/other", Name: "Baz"})
tmp.Kind = types.Struct tmp.Kind = types.Struct
tmp.Members = []types.Member{{ tmp.Members = []types.Member{{
Embedded: true, Embedded: true,
Type: base, Type: base,
}} }}
u.Get(types.Name{"", "string"}) u.Get(types.Name{Package: "", Name: "string"})
o := Orderer{NewPublicNamer(0)} o := Orderer{NewPublicNamer(0)}
order := o.Order(u) order := o.Order(u)
......
...@@ -83,6 +83,11 @@ func New() *Builder { ...@@ -83,6 +83,11 @@ func New() *Builder {
} }
} }
// AddBuildTags adds the specified build tags to the parse context.
func (b *Builder) AddBuildTags(tags ...string) {
b.context.BuildTags = append(b.context.BuildTags, tags...)
}
// Get package information from the go/build package. Automatically excludes // Get package information from the go/build package. Automatically excludes
// e.g. test files and files for other platforms-- there is quite a bit of // e.g. test files and files for other platforms-- there is quite a bit of
// logic of that nature in the build package. // logic of that nature in the build package.
......
...@@ -175,7 +175,7 @@ type Blah struct { ...@@ -175,7 +175,7 @@ type Blah struct {
_, u, o := construct(t, structTest, namer.NewPublicNamer(0)) _, u, o := construct(t, structTest, namer.NewPublicNamer(0))
t.Logf("%#v", o) t.Logf("%#v", o)
blahT := u.Get(types.Name{"base/foo/proto", "Blah"}) blahT := u.Get(types.Name{Package: "base/foo/proto", Name: "Blah"})
if blahT == nil { if blahT == nil {
t.Fatal("type not found") t.Fatal("type not found")
} }
...@@ -344,11 +344,11 @@ type Interface interface{Method(a, b string) (c, d string)} ...@@ -344,11 +344,11 @@ type Interface interface{Method(a, b string) (c, d string)}
} }
// Also do some one-off checks // Also do some one-off checks
gtest := u.Get(types.Name{"g", "Test"}) gtest := u.Get(types.Name{Package: "g", Name: "Test"})
if e, a := 1, len(gtest.Methods); e != a { if e, a := 1, len(gtest.Methods); e != a {
t.Errorf("expected %v but found %v methods: %#v", e, a, gtest) t.Errorf("expected %v but found %v methods: %#v", e, a, gtest)
} }
iface := u.Get(types.Name{"g", "Interface"}) iface := u.Get(types.Name{Package: "g", Name: "Interface"})
if e, a := 1, len(iface.Methods); e != a { if e, a := 1, len(iface.Methods); e != a {
t.Errorf("expected %v but found %v methods: %#v", e, a, iface) t.Errorf("expected %v but found %v methods: %#v", e, a, iface)
} }
......
...@@ -23,7 +23,7 @@ import ( ...@@ -23,7 +23,7 @@ import (
func TestFlatten(t *testing.T) { func TestFlatten(t *testing.T) {
mapType := &Type{ mapType := &Type{
Name: Name{"", "map[string]string"}, Name: Name{Package: "", Name: "map[string]string"},
Kind: Map, Kind: Map,
Key: String, Key: String,
Elem: String, Elem: String,
...@@ -33,7 +33,7 @@ func TestFlatten(t *testing.T) { ...@@ -33,7 +33,7 @@ func TestFlatten(t *testing.T) {
Name: "Baz", Name: "Baz",
Embedded: true, Embedded: true,
Type: &Type{ Type: &Type{
Name: Name{"pkg", "Baz"}, Name: Name{Package: "pkg", Name: "Baz"},
Kind: Struct, Kind: Struct,
Members: []Member{ Members: []Member{
{Name: "Foo", Type: String}, {Name: "Foo", Type: String},
...@@ -41,7 +41,7 @@ func TestFlatten(t *testing.T) { ...@@ -41,7 +41,7 @@ func TestFlatten(t *testing.T) {
Name: "Qux", Name: "Qux",
Embedded: true, Embedded: true,
Type: &Type{ Type: &Type{
Name: Name{"pkg", "Qux"}, Name: Name{Package: "pkg", Name: "Qux"},
Kind: Struct, Kind: Struct,
Members: []Member{{Name: "Zot", Type: String}}, Members: []Member{{Name: "Zot", Type: String}},
}, },
......
...@@ -18,10 +18,13 @@ package types ...@@ -18,10 +18,13 @@ package types
// A type name may have a package qualifier. // A type name may have a package qualifier.
type Name struct { type Name struct {
// Empty if embedded or builtin. This is the package path. // Empty if embedded or builtin. This is the package path unless Path is specified.
Package string Package string
// The type name. // The type name.
Name string Name string
// An optional location of the type definition for languages that can have disjoint
// packages and paths.
Path string
} }
// String returns the name formatted as a string. // String returns the name formatted as a string.
...@@ -104,7 +107,7 @@ func (p *Package) Get(typeName string) *Type { ...@@ -104,7 +107,7 @@ func (p *Package) Get(typeName string) *Type {
return t return t
} }
} }
t := &Type{Name: Name{p.Path, typeName}} t := &Type{Name: Name{Package: p.Path, Name: typeName}}
p.Types[typeName] = t p.Types[typeName] = t
return t return t
} }
...@@ -280,6 +283,22 @@ var ( ...@@ -280,6 +283,22 @@ var (
Name: Name{Name: "uint"}, Name: Name{Name: "uint"},
Kind: Builtin, Kind: Builtin,
} }
Uintptr = &Type{
Name: Name{Name: "uintptr"},
Kind: Builtin,
}
Float64 = &Type{
Name: Name{Name: "float64"},
Kind: Builtin,
}
Float32 = &Type{
Name: Name{Name: "float32"},
Kind: Builtin,
}
Float = &Type{
Name: Name{Name: "float"},
Kind: Builtin,
}
Bool = &Type{ Bool = &Type{
Name: Name{Name: "bool"}, Name: Name{Name: "bool"},
Kind: Builtin, Kind: Builtin,
...@@ -291,19 +310,23 @@ var ( ...@@ -291,19 +310,23 @@ var (
builtins = &Package{ builtins = &Package{
Types: map[string]*Type{ Types: map[string]*Type{
"bool": Bool, "bool": Bool,
"string": String, "string": String,
"int": Int, "int": Int,
"int64": Int64, "int64": Int64,
"int32": Int32, "int32": Int32,
"int16": Int16, "int16": Int16,
"int8": Byte, "int8": Byte,
"uint": Uint, "uint": Uint,
"uint64": Uint64, "uint64": Uint64,
"uint32": Uint32, "uint32": Uint32,
"uint16": Uint16, "uint16": Uint16,
"uint8": Byte, "uint8": Byte,
"byte": Byte, "uintptr": Uintptr,
"byte": Byte,
"float": Float,
"float64": Float64,
"float32": Float32,
}, },
Imports: map[string]*Package{}, Imports: map[string]*Package{},
Path: "", Path: "",
......
...@@ -25,7 +25,7 @@ func TestGetBuiltin(t *testing.T) { ...@@ -25,7 +25,7 @@ func TestGetBuiltin(t *testing.T) {
if builtinPkg := u.Package(""); builtinPkg.Has("string") { if builtinPkg := u.Package(""); builtinPkg.Has("string") {
t.Errorf("Expected builtin package to not have builtins until they're asked for explicitly. %#v", builtinPkg) t.Errorf("Expected builtin package to not have builtins until they're asked for explicitly. %#v", builtinPkg)
} }
s := u.Get(Name{"", "string"}) s := u.Get(Name{Package: "", Name: "string"})
if s != String { if s != String {
t.Errorf("Expected canonical string type.") t.Errorf("Expected canonical string type.")
} }
...@@ -39,7 +39,7 @@ func TestGetBuiltin(t *testing.T) { ...@@ -39,7 +39,7 @@ func TestGetBuiltin(t *testing.T) {
func TestGetMarker(t *testing.T) { func TestGetMarker(t *testing.T) {
u := Universe{} u := Universe{}
n := Name{"path/to/package", "Foo"} n := Name{Package: "path/to/package", Name: "Foo"}
f := u.Get(n) f := u.Get(n)
if f == nil || f.Name != n { if f == nil || f.Name != n {
t.Errorf("Expected marker type.") t.Errorf("Expected marker type.")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment