MCPcopy Index your code
hub / github.com/expr-lang/expr / PanicsWithValue

Function PanicsWithValue

internal/testify/assert/assertions.go:1230–1244  ·  view source on GitHub ↗

PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic value equals the expected panic value. assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })

(t TestingT, expected interface{}, f PanicTestFunc, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

1228//
1229// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() })
1230func PanicsWithValue(t TestingT, expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool {
1231 if h, ok := t.(tHelper); ok {
1232 h.Helper()
1233 }
1234
1235 funcDidPanic, panicValue, panickedStack := didPanic(f)
1236 if !funcDidPanic {
1237 return Fail(t, fmt.Sprintf("func %#v should panic\n\tPanic value:\t%#v", f, panicValue), msgAndArgs...)
1238 }
1239 if panicValue != expected {
1240 return Fail(t, fmt.Sprintf("func %#v should panic with value:\t%#v\n\tPanic value:\t%#v\n\tPanic stack:\t%s", f, expected, panicValue, panickedStack), msgAndArgs...)
1241 }
1242
1243 return true
1244}
1245
1246// PanicsWithError asserts that the code inside the specified PanicTestFunc
1247// panics, and that the recovered panic value is an error that satisfies the

Callers 4

PanicsWithValueFunction · 0.92
PanicsWithValuefFunction · 0.70
TestPanicsWithValueFunction · 0.70
PanicsWithValueMethod · 0.70

Calls 4

didPanicFunction · 0.85
SprintfMethod · 0.80
FailFunction · 0.70
HelperMethod · 0.45

Tested by 1

TestPanicsWithValueFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…