mirror of
https://github.com/golang/go
synced 2024-11-21 16:54:46 -07:00
fmt: add test of NaN map keys
R=r CC=golang-dev https://golang.org/cl/5564063
This commit is contained in:
parent
f3492a7d40
commit
e451fb8ffb
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user