Commit 02ad82fe authored by Rob Pike's avatar Rob Pike

fmt: put a ! in all error output generated by Printf-like functions

Fixes #5730.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/12141043
parent fa673bd8
......@@ -156,8 +156,8 @@
Printf("%*s", 4.5, "hi"): %!(BADWIDTH)hi
Printf("%.*s", 4.5, "hi"): %!(BADPREC)hi
Invalid or invalid use of argument index: %!(BADINDEX)
Printf("%*[2]d", 7): %d(BADINDEX)
Printf("%.[2]d", 7): %d(BADINDEX)
Printf("%*[2]d", 7): %d!(BADINDEX)
Printf("%.[2]d", 7): %d!(BADINDEX)
All errors begin with the string "%!" followed sometimes
by a single character (the verb) and end with a parenthesized
......
......@@ -563,17 +563,17 @@ var reorderTests = []struct {
{"%d %d %d %#[1]o %#o %#o", SE{11, 12, 13}, "11 12 13 013 014 015"},
// Erroneous cases.
{"%[d", SE{2, 1}, "%d(BADINDEX)"},
{"%[d", SE{2, 1}, "%d!(BADINDEX)"},
{"%]d", SE{2, 1}, "%!](int=2)d%!(EXTRA int=1)"},
{"%[]d", SE{2, 1}, "%d(BADINDEX)"},
{"%[-3]d", SE{2, 1}, "%d(BADINDEX)"},
{"%[99]d", SE{2, 1}, "%d(BADINDEX)"},
{"%[]d", SE{2, 1}, "%d!(BADINDEX)"},
{"%[-3]d", SE{2, 1}, "%d!(BADINDEX)"},
{"%[99]d", SE{2, 1}, "%d!(BADINDEX)"},
{"%[3]", SE{2, 1}, "%!(NOVERB)"},
{"%[1].2d", SE{5, 6}, "%d(BADINDEX)"},
{"%[1]2d", SE{2, 1}, "%d(BADINDEX)"},
{"%3.[2]d", SE{7}, "%d(BADINDEX)"},
{"%.[2]d", SE{7}, "%d(BADINDEX)"},
{"%d %d %d %#[1]o %#o %#o %#o", SE{11, 12, 13}, "11 12 13 013 014 015 %o(MISSING)"},
{"%[1].2d", SE{5, 6}, "%d!(BADINDEX)"},
{"%[1]2d", SE{2, 1}, "%d!(BADINDEX)"},
{"%3.[2]d", SE{7}, "%d!(BADINDEX)"},
{"%.[2]d", SE{7}, "%d!(BADINDEX)"},
{"%d %d %d %#[1]o %#o %#o %#o", SE{11, 12, 13}, "11 12 13 013 014 015 %o!(MISSING)"},
}
func TestReorder(t *testing.T) {
......@@ -877,16 +877,16 @@ var panictests = []struct {
}{
// String
{"%s", (*Panic)(nil), "<nil>"}, // nil pointer special case
{"%s", Panic{io.ErrUnexpectedEOF}, "%s(PANIC=unexpected EOF)"},
{"%s", Panic{3}, "%s(PANIC=3)"},
{"%s", Panic{io.ErrUnexpectedEOF}, "%s!(PANIC=unexpected EOF)"},
{"%s", Panic{3}, "%s!(PANIC=3)"},
// GoString
{"%#v", (*Panic)(nil), "<nil>"}, // nil pointer special case
{"%#v", Panic{io.ErrUnexpectedEOF}, "%v(PANIC=unexpected EOF)"},
{"%#v", Panic{3}, "%v(PANIC=3)"},
{"%#v", Panic{io.ErrUnexpectedEOF}, "%v!(PANIC=unexpected EOF)"},
{"%#v", Panic{3}, "%v!(PANIC=3)"},
// Format
{"%s", (*PanicF)(nil), "<nil>"}, // nil pointer special case
{"%s", PanicF{io.ErrUnexpectedEOF}, "%s(PANIC=unexpected EOF)"},
{"%s", PanicF{3}, "%s(PANIC=3)"},
{"%s", PanicF{io.ErrUnexpectedEOF}, "%s!(PANIC=unexpected EOF)"},
{"%s", PanicF{3}, "%s!(PANIC=3)"},
}
func TestPanics(t *testing.T) {
......
......@@ -21,9 +21,9 @@ var (
nilParenBytes = []byte("(nil)")
nilBytes = []byte("nil")
mapBytes = []byte("map[")
missingBytes = []byte("(MISSING)")
badIndexBytes = []byte("(BADINDEX)")
panicBytes = []byte("(PANIC=")
missingBytes = []byte("!(MISSING)")
badIndexBytes = []byte("!(BADINDEX)")
panicBytes = []byte("!(PANIC=")
extraBytes = []byte("%!(EXTRA ")
irparenBytes = []byte("i)")
bytesBytes = []byte("[]byte{")
......
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