diff --git a/src/pkg/fmt/fmt_test.go b/src/pkg/fmt/fmt_test.go index 2f92f947cd8..cd0b0ce66be 100644 --- a/src/pkg/fmt/fmt_test.go +++ b/src/pkg/fmt/fmt_test.go @@ -443,6 +443,14 @@ var fmttests = []struct { {"%s", nil, "%!s()"}, {"%T", nil, ""}, {"%-1", 100, "%!(NOVERB)%!(EXTRA int=100)"}, + + // The "" 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 . + // 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: NaN:]"}, } func TestSprintf(t *testing.T) {