diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-02-09 08:19:58 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-02-09 08:19:58 +0000 |
commit | 94252f4bcc0a3f487b804ce535cb77b8bef4db83 (patch) | |
tree | 7ca86535c5a6b99d4cc432ba5cfddabc5ee4ea16 /libgo/go/fmt | |
parent | cd6368115dbd75d9187877097c48a0d8d4c04fd4 (diff) | |
download | gcc-94252f4bcc0a3f487b804ce535cb77b8bef4db83.zip gcc-94252f4bcc0a3f487b804ce535cb77b8bef4db83.tar.gz gcc-94252f4bcc0a3f487b804ce535cb77b8bef4db83.tar.bz2 |
libgo: Update to weekly.2012-02-07.
From-SVN: r184034
Diffstat (limited to 'libgo/go/fmt')
-rw-r--r-- | libgo/go/fmt/fmt_test.go | 17 | ||||
-rw-r--r-- | libgo/go/fmt/scan.go | 1 |
2 files changed, 14 insertions, 4 deletions
diff --git a/libgo/go/fmt/fmt_test.go b/libgo/go/fmt/fmt_test.go index 504194c..1b02f52 100644 --- a/libgo/go/fmt/fmt_test.go +++ b/libgo/go/fmt/fmt_test.go @@ -443,6 +443,14 @@ var fmttests = []struct { {"%s", nil, "%!s(<nil>)"}, {"%T", nil, "<nil>"}, {"%-1", 100, "%!(NOVERB)%!(EXTRA int=100)"}, + + // The "<nil>" show up because maps are printed by + // first obtaining a list of keys and then looking up + // each key. Since NaNs can be map keys but cannot + // be fetched directly, the lookup fails and returns a + // zero reflect.Value, which formats as <nil>. + // This test is just to check that it shows the two NaNs at all. + {"%v", map[float64]int{math.NaN(): 1, math.NaN(): 2}, "map[NaN:<nil> NaN:<nil>]"}, } func TestSprintf(t *testing.T) { @@ -532,13 +540,14 @@ var _ bytes.Buffer func TestCountMallocs(t *testing.T) { for _, mt := range mallocTest { const N = 100 - runtime.UpdateMemStats() - mallocs := 0 - runtime.MemStats.Mallocs + memstats := new(runtime.MemStats) + runtime.ReadMemStats(memstats) + mallocs := 0 - memstats.Mallocs for i := 0; i < N; i++ { mt.fn() } - runtime.UpdateMemStats() - mallocs += runtime.MemStats.Mallocs + runtime.ReadMemStats(memstats) + mallocs += memstats.Mallocs if mallocs/N > uint64(mt.count) { t.Errorf("%s: expected %d mallocs, got %d", mt.desc, mt.count, mallocs/N) } diff --git a/libgo/go/fmt/scan.go b/libgo/go/fmt/scan.go index 2815251..36c6aeb 100644 --- a/libgo/go/fmt/scan.go +++ b/libgo/go/fmt/scan.go @@ -366,6 +366,7 @@ func newScanState(r io.Reader, nlIsSpace, nlIsEnd bool) (s *ss, old ssave) { s.fieldLimit = hugeWid s.maxWid = hugeWid s.validSave = true + s.count = 0 return } |