1
0
mirror of https://github.com/golang/go synced 2024-11-18 15:44:41 -07:00

go.tools/cmd/vet: update for fmt handling %b for complex numbers

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/13490048
This commit is contained in:
Rob Pike 2013-09-16 08:18:27 +10:00
parent 1928c01286
commit ece05f910e
2 changed files with 4 additions and 3 deletions

View File

@ -308,7 +308,7 @@ var printVerbs = []printVerb{
// '#' is alternate format for several verbs.
// ' ' is spacer for numbers
{'%', noFlag, 0},
{'b', numFlag, argInt | argFloat},
{'b', numFlag, argInt | argFloat | argComplex},
{'c', "-", argRune | argInt},
{'d', numFlag, argInt},
{'e', numFlag, argFloat | argComplex},

View File

@ -67,6 +67,7 @@ func PrintfTests() {
fmt.Printf("%F %F %F %F", 3e9, x, fslice, c)
fmt.Printf("%g %g %g %g", 3e9, x, fslice, c)
fmt.Printf("%G %G %G %G", 3e9, x, fslice, c)
fmt.Printf("%b %b %b %b", 3e9, x, fslice, c)
fmt.Printf("%o %o", 3, i)
fmt.Printf("%p %p", p, nil)
fmt.Printf("%q %q %q %q", 3, i, 'x', r)
@ -95,8 +96,8 @@ func PrintfTests() {
fmt.Printf("%g", 1+2i)
// Some bad format/argTypes
fmt.Printf("%b", "hi") // ERROR "arg .hi. for printf verb %b of wrong type"
fmt.Printf("%b", c) // ERROR "arg c for printf verb %b of wrong type"
fmt.Printf("%b", 1+2i) // ERROR "arg 1 \+ 2i for printf verb %b of wrong type"
fmt.Printf("%t", c) // ERROR "arg c for printf verb %t of wrong type"
fmt.Printf("%t", 1+2i) // ERROR "arg 1 \+ 2i for printf verb %t of wrong type"
fmt.Printf("%c", 2.3) // ERROR "arg 2.3 for printf verb %c of wrong type"
fmt.Printf("%d", 2.3) // ERROR "arg 2.3 for printf verb %d of wrong type"
fmt.Printf("%e", "hi") // ERROR "arg .hi. for printf verb %e of wrong type"