OLD | NEW |
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // This file contains the code to check canonical methods. | 5 // This file contains the code to check canonical methods. |
6 | 6 |
7 package main | 7 package main |
8 | 8 |
9 import ( | 9 import ( |
10 "fmt" | 10 "fmt" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 expectFmt += " " + argjoin(expect.results) | 83 expectFmt += " " + argjoin(expect.results) |
84 } else if len(expect.results) > 1 { | 84 } else if len(expect.results) > 1 { |
85 expectFmt += " (" + argjoin(expect.results) + ")" | 85 expectFmt += " (" + argjoin(expect.results) + ")" |
86 } | 86 } |
87 | 87 |
88 f.b.Reset() | 88 f.b.Reset() |
89 if err := printer.Fprint(&f.b, f.fset, t); err != nil { | 89 if err := printer.Fprint(&f.b, f.fset, t); err != nil { |
90 fmt.Fprintf(&f.b, "<%s>", err) | 90 fmt.Fprintf(&f.b, "<%s>", err) |
91 } | 91 } |
92 actual := f.b.String() | 92 actual := f.b.String() |
93 » » actual = strings.TrimPrefix(actual, "func(") | 93 » » actual = strings.TrimPrefix(actual, "func") |
94 actual = id.Name + actual | 94 actual = id.Name + actual |
95 | 95 |
96 f.Warnf(id.Pos(), "method %s should have signature %s", actual,
expectFmt) | 96 f.Warnf(id.Pos(), "method %s should have signature %s", actual,
expectFmt) |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 func argjoin(x []string) string { | 100 func argjoin(x []string) string { |
101 y := make([]string, len(x)) | 101 y := make([]string, len(x)) |
102 for i, s := range x { | 102 for i, s := range x { |
103 if s[0] == '=' { | 103 if s[0] == '=' { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 printer.Fprint(&f.b, f.fset, actual) | 160 printer.Fprint(&f.b, f.fset, actual) |
161 return f.b.String() == expect | 161 return f.b.String() == expect |
162 } | 162 } |
163 | 163 |
164 func (t *BadTypeUsedInTests) Scan(x fmt.ScanState, c byte) { // ERROR "should ha
ve signature Scan" | 164 func (t *BadTypeUsedInTests) Scan(x fmt.ScanState, c byte) { // ERROR "should ha
ve signature Scan" |
165 } | 165 } |
166 | 166 |
167 type BadInterfaceUsedInTests interface { | 167 type BadInterfaceUsedInTests interface { |
168 ReadByte() byte // ERROR "should have signature ReadByte" | 168 ReadByte() byte // ERROR "should have signature ReadByte" |
169 } | 169 } |
OLD | NEW |