Commit e451fb8f authored by Russ Cox's avatar Russ Cox

fmt: add test of NaN map keys

R=r
CC=golang-dev
https://golang.org/cl/5564063
parent f3492a7d
......@@ -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) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment