mirror of
https://github.com/golang/go
synced 2024-11-23 17:30:02 -07:00
cmd/vet: add a test for embedded stringer
This should help narrowing down the possible cause of #20514. Updates #20514. Change-Id: Ie997400c9749aace7783bd585b23dbb4cefc181d Reviewed-on: https://go-review.googlesource.com/44375 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
7cd6310014
commit
708a01fbf4
13
src/cmd/vet/testdata/print.go
vendored
13
src/cmd/vet/testdata/print.go
vendored
@ -87,6 +87,9 @@ func PrintfTests() {
|
||||
fmt.Printf("%s", &stringerv)
|
||||
fmt.Printf("%v", &stringerv)
|
||||
fmt.Printf("%T", &stringerv)
|
||||
fmt.Printf("%s", &embeddedStringerv)
|
||||
fmt.Printf("%v", &embeddedStringerv)
|
||||
fmt.Printf("%T", &embeddedStringerv)
|
||||
fmt.Printf("%v", notstringerv)
|
||||
fmt.Printf("%T", notstringerv)
|
||||
fmt.Printf("%q", stringerarrayv)
|
||||
@ -123,6 +126,8 @@ func PrintfTests() {
|
||||
fmt.Printf("%X", 2.3) // ERROR "arg 2.3 for printf verb %X of wrong type"
|
||||
fmt.Printf("%s", stringerv) // ERROR "arg stringerv for printf verb %s of wrong type"
|
||||
fmt.Printf("%t", stringerv) // ERROR "arg stringerv for printf verb %t of wrong type"
|
||||
fmt.Printf("%s", embeddedStringerv) // ERROR "arg embeddedStringerv for printf verb %s of wrong type"
|
||||
fmt.Printf("%t", embeddedStringerv) // ERROR "arg embeddedStringerv for printf verb %t of wrong type"
|
||||
fmt.Printf("%q", notstringerv) // ERROR "arg notstringerv for printf verb %q of wrong type"
|
||||
fmt.Printf("%t", notstringerv) // ERROR "arg notstringerv for printf verb %t of wrong type"
|
||||
fmt.Printf("%t", stringerarrayv) // ERROR "arg stringerarrayv for printf verb %t of wrong type"
|
||||
@ -346,6 +351,14 @@ func (*stringer) Warnf(int, string, ...interface{}) string {
|
||||
return "warnf"
|
||||
}
|
||||
|
||||
type embeddedStringer struct {
|
||||
foo string
|
||||
stringer
|
||||
bar int
|
||||
}
|
||||
|
||||
var embeddedStringerv embeddedStringer
|
||||
|
||||
type notstringer struct {
|
||||
f float64
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user