summaryrefslogtreecommitdiff
path: root/src/pkg/fmt/fmt_test.go
AgeCommit message (Collapse)AuthorFilesLines
2011-09-13Imported Upstream version 60upstream/60Ondřej Surý1-0/+746
2011-09-13Imported Upstream version 60Ondřej Surý1-738/+0
2011-08-03Imported Upstream version 59upstream/59Ondřej Surý1-0/+62
2011-06-30Imported Upstream version 58upstream/58Ondřej Surý1-5/+16
2011-04-26Imported Upstream version 2011.04.13upstream/2011.04.13Ondřej Surý1-0/+14
2011-04-20Imported Upstream version 2011.03.07.1upstream/2011.03.07.1Ondřej Surý1-10/+11
2011-02-14Imported Upstream version 2011-02-01.1upstream/2011-02-01.1Ondřej Surý1-36/+32
2011-01-17Imported Upstream version 2011.01.12upstream/2011.01.12Ondřej Surý1-243/+369
2010-06-28fmt.Printf: fix bug in handling of %#v.Rob Pike1-0/+8
nice side effect: slices now obey their format verb. example: fmt.Printf("%q\n", []string{"a"}) R=rsc CC=golang-dev http://codereview.appspot.com/1729045
2010-06-14fmt.Printf: write tests for %T.Rob Pike1-0/+6
Fix a bug that caused it to ignore field widths. R=rsc CC=golang-dev http://codereview.appspot.com/1704041
2010-06-14fmt.Print*: reimplement to switch on type first.Rob Pike1-1/+55
This shortens, simplifies and regularizes the code significantly. (Improvements to reflect could make another step.) Passes all.bash. One semantic change occurs: The String() method changes behavior. It used to run only for string formats such as %s and %q. Instead, it now runs whenever the item has the method and the result is then processed by the format as a string. Besides the regularization, this has three effects: 1) width is honored for String() items 2) %x works for String() items 3) implementations of String that merely recur will recur forever Regarding point 3, example from the updated documentation: type X int func (x X) String() string { return Sprintf("%d", x) } should cast the value before recurring: func (x X) String() string { return Sprintf("%d", int(x)) } R=rsc CC=golang-dev http://codereview.appspot.com/1613045
2010-05-31fmt: fix end-of-array error in parsenum.Rob Pike1-0/+1
Fixes issue 821. R=rsc CC=golang-dev http://codereview.appspot.com/1434041
2010-04-28fmt: %T print <nil> for nilChristopher Wedgwood1-0/+1
R=r CC=golang-dev, rsc http://codereview.appspot.com/1014043 Committer: Rob Pike <r@golang.org>
2010-04-12fmt format verb %b bugAndrei Vieru1-0/+1
fmt.Printf("%b", int8(-1)) prints 64 ones instead of 8. This happens only for signed integers (int8, in16 and int32). I guess it's because of the way the conversion between integer types works. From go spec: "Conversions between integer types. If the value is a signed quantity, it is sign extended to implicit infinite precision ....". And there are several conversions to int64 and uint64 in the fmt package. This pathch solves only half of the problem. On a 32 bit system, an fmt.Printf("%b", int(-1)) should still print 64 ones. R=golang-dev, r CC=golang-dev http://codereview.appspot.com/891049 Committer: Rob Pike <r@golang.org>
2010-03-09fmt: enable the complex tests now that 8g supports complexRob Pike1-4/+0
R=rsc CC=golang-dev http://codereview.appspot.com/357043
2010-03-06fix bug in complex printing: imaginary didn't have same format as real.Rob Pike1-0/+29
add tests. R=rsc, ken2, ken3 CC=golang-dev http://codereview.appspot.com/261041
2010-02-28Count utf8 runes, not bytes when determining string width. NoteStephen Ma1-0/+1
that pad() still counts bytes, but it's currently only used for 1 byte runes. Fixes issue 612. R=r CC=golang-dev http://codereview.appspot.com/217064 Committer: Rob Pike <r@golang.org>
2010-02-25strings: delete Runes, BytesRuss Cox1-6/+6
gofmt -w -r 'strings.Bytes(a) -> []byte(a)' src/cmd src/pkg test/bench gofmt -w -r 'strings.Runes(a) -> []int(a)' src/cmd src/pkg test/bench delete unused imports R=r CC=golang-dev http://codereview.appspot.com/224062
2010-02-25%q in fmt: if the object is a Stringer, use String() to get the value to quote.Rob Pike1-0/+3
R=rsc CC=golang-dev http://codereview.appspot.com/224051
2010-02-05handle nils safely in Printf.Rob Pike1-0/+5
add some tests for erroneous formats. R=rsc CC=golang-dev http://codereview.appspot.com/201058
2010-02-03finalizers; merge package malloc into package runtimeRuss Cox1-9/+9
R=r, cw CC=golang-dev http://codereview.appspot.com/198085
2009-12-22Allow %p on reference types, for debugging.Rob Pike1-1/+6
(Also fix case sensitivity in test for PTR inside fmt_test.go) Fixes issue 441. R=rsc, iant CC=golang-dev http://codereview.appspot.com/180112
2009-12-15 1) Change default gofmt default settings forRobert Griesemer1-66/+66
parsing and printing to new syntax. Use -oldparser to parse the old syntax, use -oldprinter to print the old syntax. 2) Change default gofmt formatting settings to use tabs for indentation only and to use spaces for alignment. This will make the code alignment insensitive to an editor's tabwidth. Use -spaces=false to use tabs for alignment. 3) Manually changed src/exp/parser/parser_test.go so that it doesn't try to parse the parser's source files using the old syntax (they have new syntax now). 4) gofmt -w src misc test/bench 2nd set of files. R=rsc CC=golang-dev http://codereview.appspot.com/179067
2009-12-06Make printing faster by avoiding mallocs and some other advances.Rob Pike1-1/+35
Roughly 33% faster for simple cases, probably more for complex ones. Before: mallocs per Sprintf(""): 4 mallocs per Sprintf("xxx"): 6 mallocs per Sprintf("%x"): 10 mallocs per Sprintf("%x %x"): 12 Now: mallocs per Sprintf(""): 2 mallocs per Sprintf("xxx"): 3 mallocs per Sprintf("%x"): 5 mallocs per Sprintf("%x %x"): 7 Speed improves because of avoiding mallocs and also by sharing a bytes.Buffer between print.go and format.go rather than copying the data back after each printed item. Before: fmt_test.BenchmarkSprintfEmpty 1000000 1346 ns/op fmt_test.BenchmarkSprintfString 500000 3461 ns/op fmt_test.BenchmarkSprintfInt 500000 3671 ns/op Now: fmt_test.BenchmarkSprintfEmpty 2000000 995 ns/op fmt_test.BenchmarkSprintfString 1000000 2745 ns/op fmt_test.BenchmarkSprintfInt 1000000 2391 ns/op fmt_test.BenchmarkSprintfIntInt 500000 3751 ns/op I believe there is more to get but this is a good milestone. R=rsc CC=golang-dev, hong http://codereview.appspot.com/166076
2009-11-24Add benchmarks for commonly used routines.Trevor Strohman1-0/+18
R=rsc, r, r1 http://codereview.appspot.com/160046 Committer: Russ Cox <rsc@golang.org>
2009-11-20gofmt -r 'α[β:len(α)] -> α[β:]' -w src/cmd src/pkgRuss Cox1-1/+1
R=r, gri CC=golang-dev http://codereview.appspot.com/156115
2009-11-20add unimplemented %+ and % (space) flags to floating-point print.Rob Pike1-0/+14
fix %E: was same as %e. add tests. Fixes issue 278. R=rsc CC=golang-dev http://codereview.appspot.com/157111
2009-11-17add a test for %+v in nested structures.Rob Pike1-0/+18
threw in an embedded one for good measure. R=rsc CC=golang-dev http://codereview.appspot.com/157058
2009-11-09 - replaced gofmt expression formatting algorithm withRobert Griesemer1-2/+2
rsc's algorithm - applied gofmt -w misc src - partial CL (remaining files in other CLs) R=rsc, r http://go/go-review/1026036
2009-11-09remove semis after statements in one-statement statement listsRobert Griesemer1-14/+14
R=rsc, r http://go/go-review/1025029
2009-11-05gofmt-ify template, time, unsafe, flag, fmtRobert Griesemer1-5/+5
(replacement for CLs 1017039, 1017041, 1017040, 1018054) R=r http://go/go-review/1018060
2009-10-06apply gofmt to datafmt, ebnf, exec, expvar, flag, fmtRuss Cox1-171/+173
R=gri DELTA=456 (6 added, 3 deleted, 447 changed) OCL=35398 CL=35406
2009-09-17unused importsRuss Cox1-1/+0
R=r OCL=34731 CL=34731
2009-09-15more "declared and not used".Russ Cox1-4/+4
the last round omitted := range and only checked 1 out of N vars in a multi-var := R=r OCL=34624 CL=34638
2009-08-31fmt: add verbs:Russ Cox1-7/+50
%E - upper case %e %G - upper case %g %#v - Go syntax R=r DELTA=332 (238 added, 47 deleted, 47 changed) OCL=34091 CL=34145
2009-08-28print the value using (in effect) %v when Printf is given mismatched args ↵Rob Pike1-0/+4
for its format Printf("%s", 2) gives %s(int=2) R=rsc DELTA=12 (10 added, 0 deleted, 2 changed) OCL=34042 CL=34044
2009-08-12convert low-level (used by testing) packages toRuss Cox1-2/+2
whole-package compilation. new Makefiles, tests now in separate package bytes flag fmt io math once os reflect strconv sync time utf8 delete import "xxx" in package xxx. inside package xxx, xxx is not declared anymore so s/xxx.//g delete file and package level forward declarations. note the new internal_test.go and sync and strconv to provide public access to internals during testing. the installed version of the package omits that file and thus does not open the internals to all clients. R=r OCL=33065 CL=33097
2009-08-03don't crash printing a nil mapRob Pike1-0/+14
R=rsc DELTA=19 (18 added, 0 deleted, 1 changed) OCL=32656 CL=32670
2009-07-09printing mapsRob Pike1-17/+41
R=rsc DELTA=57 (39 added, 3 deleted, 15 changed) OCL=31424 CL=31430
2009-06-29io.StringBytes -> strings.BytesRuss Cox1-6/+7
io.ByteBuffer -> bytes.Buffer left io.ByteBuffer stub around for now, for protocol compiler. R=r OCL=30861 CL=30872
2009-06-23rename Formatter to State and Format to Formatter, for nomenclatural consistencyRob Pike1-1/+1
R=rsc DELTA=9 (0 added, 0 deleted, 9 changed) OCL=30658 CL=30658
2009-06-09mv src/lib to src/pkgRob Pike1-0/+247
tests: all.bash passes, gobuild still works, godoc still works. R=rsc OCL=30096 CL=30102