1 // Copyright ©2013 The Gonum Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 func leaksPanic(fn func()) (panicked bool) {
18 func TestMaybe(t *testing.T) {
19 for i, test := range []struct {
30 fn: func() { panic("panic") },
35 fn: func() { panic(Error{"panic"}) },
40 panicked := leaksPanic(test.fn)
41 if panicked != test.panics {
42 t.Errorf("unexpected panic state for test %d: got: panicked=%t want: panicked=%t",
43 i, panicked, test.panics)
47 stack, ok := err.(ErrorStack)
49 t.Errorf("unexpected error type: got:%T want:%T", stack, ErrorStack{})
51 if stack.StackTrace == "" {
52 t.Error("expected non-empty stack trace")