@@ -30,9 +30,21 @@ func (f *fakeT) Fatalf(format string, args ...any) {
3030 f .fatalMsg = fmt .Sprintf (format , args ... )
3131 panic (fatalSentinel {f .fatalMsg })
3232}
33+ func (f * fakeT ) Fatal (args ... any ) {
34+ f .failed = true
35+ f .fatalMsg = fmt .Sprint (args ... )
36+ panic (fatalSentinel {f .fatalMsg })
37+ }
38+ func (f * fakeT ) FailNow () {
39+ f .failed = true
40+ panic (fatalSentinel {})
41+ }
42+ func (f * fakeT ) Skip (args ... any ) {
43+ panic (fatalSentinel {fmt .Sprint (args ... )})
44+ }
3345
34- // expectFatal calls fn and returns true if it triggered fakeT.Fatalf .
35- func expectFatal (ft * fakeT , fn func ()) bool {
46+ // expectFatal calls fn and recovers if it triggered a fakeT fatal/skip .
47+ func expectFatal (ft * fakeT , fn func ()) {
3648 defer func () {
3749 if r := recover (); r != nil {
3850 if _ , ok := r .(fatalSentinel ); ! ok {
@@ -41,10 +53,6 @@ func expectFatal(ft *fakeT, fn func()) bool {
4153 }
4254 }()
4355 fn ()
44- return false // no fatal occurred
45- // unreachable after panic, but if Fatalf fired the deferred
46- // recover runs and the function returns the zero value (false);
47- // callers should check ft.failed instead.
4856}
4957
5058func TestAddLabel_ValidName (t * testing.T ) {
0 commit comments