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