MCPcopy
hub / github.com/stretchr/testify / didPanic

Function didPanic

assert/assertions.go:1280–1295  ·  view source on GitHub ↗

didPanic returns true if the function passed to it panics. Otherwise, it returns false.

(f PanicTestFunc)

Source from the content-addressed store, hash-verified

1278
1279// didPanic returns true if the function passed to it panics. Otherwise, it returns false.
1280func didPanic(f PanicTestFunc) (didPanic bool, message interface{}, stack string) {
1281 didPanic = true
1282
1283 defer func() {
1284 message = recover()
1285 if didPanic {
1286 stack = string(debug.Stack())
1287 }
1288 }()
1289
1290 // call the target function
1291 f()
1292 didPanic = false
1293
1294 return
1295}
1296
1297// Panics asserts that the code inside the specified PanicTestFunc panics.
1298//

Callers 6

TestDidPanicWrapperFunction · 0.85
TestDidPanicFunction · 0.85
PanicsFunction · 0.85
PanicsWithValueFunction · 0.85
PanicsWithErrorFunction · 0.85
NotPanicsFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestDidPanicWrapperFunction · 0.68
TestDidPanicFunction · 0.68