diff options
author | Rob Pike <r@golang.org> | 2010-06-14 17:42:31 -0700 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2010-06-14 17:42:31 -0700 |
commit | cdc700c29a00bc78660cc6725ec9b4ef621c39a1 (patch) | |
tree | 960f1edf6da92537b5498c84d87761f907227f13 /src | |
parent | dcabff01961349b411c3f17f7afb82255578ca30 (diff) | |
download | golang-cdc700c29a00bc78660cc6725ec9b4ef621c39a1.tar.gz |
fmt.Printf: write tests for %T.
Fix a bug that caused it to ignore field widths.
R=rsc
CC=golang-dev
http://codereview.appspot.com/1704041
Diffstat (limited to 'src')
-rw-r--r-- | src/pkg/fmt/fmt_test.go | 6 | ||||
-rw-r--r-- | src/pkg/fmt/print.go | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/pkg/fmt/fmt_test.go b/src/pkg/fmt/fmt_test.go index d9bb167dd..e48e874b1 100644 --- a/src/pkg/fmt/fmt_test.go +++ b/src/pkg/fmt/fmt_test.go @@ -314,6 +314,12 @@ var fmttests = []fmtTest{ fmtTest{"%v", renamedComplex64(3 + 4i), "(3+4i)"}, fmtTest{"%v", renamedComplex128(4 - 3i), "(4-3i)"}, + // %T + fmtTest{"%T", (4 - 3i), "complex"}, + fmtTest{"%T", renamedComplex128(4 - 3i), "fmt_test.renamedComplex128"}, + fmtTest{"%T", intVal, "int"}, + fmtTest{"%6T", &intVal, " *int"}, + // erroneous things fmtTest{"%d", "hello", "%d(string=hello)"}, fmtTest{"no args", "hello", "no args?(extra string=hello)"}, diff --git a/src/pkg/fmt/print.go b/src/pkg/fmt/print.go index 31bd1f6f7..16ab71952 100644 --- a/src/pkg/fmt/print.go +++ b/src/pkg/fmt/print.go @@ -959,7 +959,7 @@ func (p *pp) doPrintf(format string, a []interface{}) { p.buf.Write(nilAngleBytes) break } - p.buf.WriteString(reflect.Typeof(field).String()) + p.printField(reflect.Typeof(field).String(), 's', false, false, 0) continue } |