Commit 708a01fb authored by Aliaksandr Valialkin's avatar Aliaksandr Valialkin Committed by Rob Pike

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/44375Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarRob Pike <r@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 7cd63100
......@@ -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
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment