From e451fb8ffbca501b12611f97ec875e9544339aa0 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 30 Jan 2012 13:20:38 -0500 Subject: [PATCH] fmt: add test of NaN map keys R=r CC=golang-dev https://golang.org/cl/5564063 --- src/pkg/fmt/fmt_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/pkg/fmt/fmt_test.go b/src/pkg/fmt/fmt_test.go index 2f92f947cd..cd0b0ce66b 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) { -- 2.50.0