mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/doc: add test for constructor, fix build
Most important: skip test on darwin/arm64 for unclear reasons. First cut at the test missed this feature of go doc: when asking for the docs for a type, include any function that looks like it constructs a that type as a return value. Change-Id: I124e7695e5d365e2b12524b541a9a4e6e0300fbc Reviewed-on: https://go-review.googlesource.com/11295 Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
parent
79d4d6eca4
commit
13c44d27b7
2 changed files with 10 additions and 0 deletions
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"runtime"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -212,6 +213,7 @@ var tests = []test{
|
||||||
`Has unexported fields`,
|
`Has unexported fields`,
|
||||||
`func \(ExportedType\) ExportedMethod\(a int\) bool`,
|
`func \(ExportedType\) ExportedMethod\(a int\) bool`,
|
||||||
`const ExportedTypedConstant ExportedType = iota`, // Must include associated constant.
|
`const ExportedTypedConstant ExportedType = iota`, // Must include associated constant.
|
||||||
|
`func ExportedTypeConstructor\(\) \*ExportedType`, // Must include constructor.
|
||||||
},
|
},
|
||||||
[]string{
|
[]string{
|
||||||
`unexportedField`, // No unexported field.
|
`unexportedField`, // No unexported field.
|
||||||
|
|
@ -297,6 +299,9 @@ var tests = []test{
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDoc(t *testing.T) {
|
func TestDoc(t *testing.T) {
|
||||||
|
if runtime.GOOS == "darwin" && runtime.GOARCH == "arm64" {
|
||||||
|
t.Skip("TODO: on darwin/arm, test fails: no such package cmd/doc/testdata")
|
||||||
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
var flagSet flag.FlagSet
|
var flagSet flag.FlagSet
|
||||||
|
|
|
||||||
5
src/cmd/doc/testdata/pkg.go
vendored
5
src/cmd/doc/testdata/pkg.go
vendored
|
|
@ -66,6 +66,11 @@ const (
|
||||||
ExportedTypedConstant ExportedType = iota
|
ExportedTypedConstant ExportedType = iota
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Comment about constructor for exported type.
|
||||||
|
func ExportedTypeConstructor() *ExportedType {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
const unexportedTypedConstant ExportedType = 1 // In a separate section to test -u.
|
const unexportedTypedConstant ExportedType = 1 // In a separate section to test -u.
|
||||||
|
|
||||||
// Comment about unexported type.
|
// Comment about unexported type.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue