Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit c838558

Browse files
authored
Improve failure message for NotPanics (#75)
1 parent a05b8c4 commit c838558

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

panic.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package verify
22

3+
import "fmt"
4+
35
// Panics tests if the function panics when executed.
46
func Panics(fn func()) (msg FailureMessage) {
57
defer func() {
@@ -15,7 +17,7 @@ func Panics(fn func()) (msg FailureMessage) {
1517
func NotPanics(fn func()) (msg FailureMessage) {
1618
defer func() {
1719
if r := recover(); r != nil {
18-
msg = "the function panicked"
20+
msg = FailureMessage(fmt.Sprintf("the function panicked\ngot: %v", r))
1921
}
2022
}()
2123
fn()

0 commit comments

Comments
 (0)