Skip to content

Commit

Permalink
mtest: collapse redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
creachadair committed Jan 6, 2025
1 parent 5a8aec3 commit 4486295
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions mtest/mtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ type TB interface {
// MustPanic executes a function f that is expected to panic.
// If it does so, MustPanic returns the value recovered from the
// panic. Otherwise, it logs a fatal error in t.
func MustPanic(t TB, f func()) (val any) {
func MustPanic(t TB, f func()) any {
t.Helper()
defer func() { val = recover() }()
f()
t.Fatalf("expected panic was not observed")
return
return MustPanicf(t, f, "expected panic was not observed")
}

// MustPanicf executes a function f that is expected to panic. If it does so,
Expand Down

0 comments on commit 4486295

Please sign in to comment.