aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/doc/testdata
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2015-06-19 12:39:02 +1000
committerRob Pike <r@golang.org>2015-06-19 21:56:59 +0000
commitd0652e7f82da12e84fb143c4ad6c19e39f238f05 (patch)
treea51e213ea5f835e1cfbbcc577905ab8aa8e9d337 /src/cmd/doc/testdata
parent5ac5a9856288d20634ac21b457ec458f19ea0a37 (diff)
downloadgo-d0652e7f82da12e84fb143c4ad6c19e39f238f05.tar.xz
cmd/doc: add test
Refactor main a bit to make it possible to run tests without an exec every time. (Makes a huge difference in run time.) Add a silver test. Not quite golden, since it looks for pieces rather than the full output, and also includes tests for what should not appear. Fixes #10920. Change-Id: I6a4951cc14e61763379754a10b0cc3484d30c267 Reviewed-on: https://go-review.googlesource.com/11272 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Rob Pike <r@golang.org>
Diffstat (limited to 'src/cmd/doc/testdata')
-rw-r--r--src/cmd/doc/testdata/pkg.go91
1 files changed, 91 insertions, 0 deletions
diff --git a/src/cmd/doc/testdata/pkg.go b/src/cmd/doc/testdata/pkg.go
new file mode 100644
index 0000000000..ccc2ed64e0
--- /dev/null
+++ b/src/cmd/doc/testdata/pkg.go
@@ -0,0 +1,91 @@
+// Copyright 2015 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 comment.
+package pkg
+
+// Constants
+
+// Comment about exported constant.
+const ExportedConstant = 1
+
+// Comment about internal constant.
+const internalConstant = 2
+
+// Comment about block of constants.
+const (
+ // Comment before ConstOne.
+ ConstOne = 1
+ ConstTwo = 2 // Comment on line with ConstTwo.
+ constThree = 3 // Comment on line with constThree.
+)
+
+// Variables
+
+// Comment about exported variable.
+const ExportedVariable = 1
+
+// Comment about internal variable.
+const internalVariable = 2
+
+// Comment about block of variables.
+const (
+ // Comment before VarOne.
+ VarOne = 1
+ VarTwo = 2 // Comment on line with VarTwo.
+ varThree = 3 // Comment on line with varThree.
+)
+
+// Comment about exported function.
+func ExportedFunc(a int) bool
+
+// Comment about internal function.
+func internalFunc(a int) bool
+
+// Comment about exported type.
+type ExportedType struct {
+ // Comment before exported field.
+ ExportedField int
+ unexportedField int // Comment on line with unexported field.
+}
+
+// Comment about exported method.
+func (ExportedType) ExportedMethod(a int) bool {
+ return true
+}
+
+// Comment about unexported method.
+func (ExportedType) unexportedMethod(a int) bool {
+ return true
+}
+
+// Constants tied to ExportedType. (The type is a struct so this isn't valid Go,
+// but it parses and that's all we need.)
+const (
+ ExportedTypedConstant ExportedType = iota
+)
+
+const unexportedTypedConstant ExportedType = 1 // In a separate section to test -u.
+
+// Comment about unexported type.
+type unexportedType int
+
+func (unexportedType) ExportedMethod() bool {
+ return true
+}
+
+func (unexportedType) unexportedMethod() bool {
+ return true
+}
+
+// Constants tied to unexportedType.
+const (
+ ExportedTypedConstant_unexported unexportedType = iota
+)
+
+const unexportedTypedConstant unexportedType = 1 // In a separate section to test -u.
+
+// For case matching.
+const CaseMatch = 1
+const Casematch = 2