diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2016-04-28 22:04:30 -0500 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-04-29 03:20:51 +0000 |
| commit | c884f6594a594d2d18c4d21106592bd3cdfcbe9b (patch) | |
| tree | 7e6127e3dae428501da925cac185aebe8a623fa0 /src/context/context_test.go | |
| parent | 694846a548f23cebb9b913999fa4fa6756e2c545 (diff) | |
| download | go-c884f6594a594d2d18c4d21106592bd3cdfcbe9b.tar.xz | |
context: produce a nicer panic message for a nil WithValue key
Change-Id: I2e8ae403622ba7131cadaba506100d79613183f1
Reviewed-on: https://go-review.googlesource.com/22601
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
Diffstat (limited to 'src/context/context_test.go')
| -rw-r--r-- | src/context/context_test.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/context/context_test.go b/src/context/context_test.go index aa26161d2b..99456b188d 100644 --- a/src/context/context_test.go +++ b/src/context/context_test.go @@ -583,6 +583,10 @@ func TestWithValueChecksKey(t *testing.T) { if panicVal == nil { t.Error("expected panic") } + panicVal = recoveredValue(func() { WithValue(Background(), nil, "bar") }) + if got, want := fmt.Sprint(panicVal), "nil key"; got != want { + t.Errorf("panic = %q; want %q", got, want) + } } func recoveredValue(fn func()) (v interface{}) { |
