GoPLS Viewer

Home|gopls/go/analysis/passes/tests/testdata/src/a/a_test.go
1package a
2
3import (
4    "testing"
5)
6
7// Buf is a ...
8type Buf []byte
9
10// Append ...
11func (*BufAppend([]byte) {}
12
13func (BufReset() {}
14
15func (BufLen() int { return 0 }
16
17// DefaultBuf is a ...
18var DefaultBuf Buf
19
20func Example() {} // OK because is package-level.
21
22func Example_goodSuffix() {} // OK because refers to suffix annotation.
23
24func Example_BadSuffix() {} // want "Example_BadSuffix has malformed example suffix: BadSuffix"
25
26func ExampleBuf() {} // OK because refers to known top-level type.
27
28func ExampleBuf_Append() {} // OK because refers to known method.
29
30func ExampleBuf_Clear() {} // want "ExampleBuf_Clear refers to unknown field or method: Buf.Clear"
31
32func ExampleBuf_suffix() {} // OK because refers to suffix annotation.
33
34func ExampleBuf_Append_Bad() {} // want "ExampleBuf_Append_Bad has malformed example suffix: Bad"
35
36func ExampleBuf_Append_suffix() {} // OK because refers to known method with valid suffix.
37
38func ExampleDefaultBuf() {} // OK because refers to top-level identifier.
39
40func ExampleBuf_Reset() bool { return true } // want "ExampleBuf_Reset should return nothing"
41
42func ExampleBuf_Len(i int) {} // want "ExampleBuf_Len should be niladic"
43
44// "Puffer" is German for "Buffer".
45
46func ExamplePuffer() {} // want "ExamplePuffer refers to unknown identifier: Puffer"
47
48func ExamplePuffer_Append() {} // want "ExamplePuffer_Append refers to unknown identifier: Puffer"
49
50func ExamplePuffer_suffix() {} // want "ExamplePuffer_suffix refers to unknown identifier: Puffer"
51
52func ExampleFoo() {} // OK because a.Foo exists
53
54func ExampleBar() {} // want "ExampleBar refers to unknown identifier: Bar"
55
56func Example_withOutput() {
57    // Output:
58    // meow
59// OK because output is the last comment block
60
61func Example_withBadOutput() {
62    // Output: // want "output comment block must be the last comment block"
63    // meow
64
65    // todo: change to bark
66}
67
68func Example_withBadUnorderedOutput() {
69    // Unordered Output: // want "output comment block must be the last comment block"
70    // meow
71
72    // todo: change to bark
73}
74
75func Example_withCommentAfterFunc() {
76    // Output: // OK because it is the last comment block
77    // meow
78// todo: change to bark
79
80func Example_withOutputCommentAfterFunc() {
81    // Output:
82    // meow
83// Output: bark // OK because output is not inside of an example
84
85func Example_withMultipleOutputs() {
86    // Output: // want "there can only be one output comment block per example"
87    // meow
88
89    // Output: // want "there can only be one output comment block per example"
90    // bark
91
92    // Output: // OK because it is the last output comment block
93    // ribbit
94}
95
96func nonTest() {} // OK because it doesn't start with "Test".
97
98func (BufTesthasReceiver() {} // OK because it has a receiver.
99
100func TestOKSuffix(*testing.T) {} // OK because first char after "Test" is Uppercase.
101
102func TestÜnicodeWorks(*testing.T) {} // OK because the first char after "Test" is Uppercase.
103
104func TestbadSuffix(*testing.T) {} // want "first letter after 'Test' must not be lowercase"
105
106func TestemptyImportBadSuffix(*testing.T) {} // want "first letter after 'Test' must not be lowercase"
107
108func Test(*testing.T) {} // OK "Test" on its own is considered a test.
109
110func Testify() {} // OK because it takes no parameters.
111
112func TesttooManyParams(*testing.Tstring) {} // OK because it takes too many parameters.
113
114func TesttooManyNames(ab *testing.T) {} // OK because it takes too many names.
115
116func TestnoTParam(string) {} // OK because it doesn't take a *testing.T
117
118func BenchmarkbadSuffix(*testing.B) {} // want "first letter after 'Benchmark' must not be lowercase"
119
MembersX
TestÜnicodeWorks
Buf.Append
ExampleBuf_suffix
ExamplePuffer
Example_BadSuffix
ExampleBuf_Append
ExampleBar
Example_withBadUnorderedOutput
nonTest
Buf.Reset
DefaultBuf
Example
TesttooManyNames.b
Example_withCommentAfterFunc
TestbadSuffix
TestemptyImportBadSuffix
TesttooManyNames
testing
ExampleDefaultBuf
ExampleFoo
Buf.TesthasReceiver
BenchmarkbadSuffix
Test
Testify
TestnoTParam
ExampleBuf_Append_Bad
ExampleBuf_Len.i
Example_withOutputCommentAfterFunc
ExampleBuf_Len
ExamplePuffer_suffix
Example_withMultipleOutputs
TestOKSuffix
TesttooManyParams
ExampleBuf
ExampleBuf_Clear
ExampleBuf_Append_suffix
Buf.Len
Example_withBadOutput
ExamplePuffer_Append
Example_withOutput
TesttooManyNames.a
Buf
Example_goodSuffix
ExampleBuf_Reset
Members
X