File tree 3 files changed +21
-3
lines changed
3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -99,8 +99,7 @@ func PushTester(t testing.TB, a ...defInd) function {
99
99
} else if Default ()& AsserterUnitTesting == 0 {
100
100
// if this is forgotten or tests don't have proper place to set it
101
101
// it's good to keep the API as simple as possible
102
- SetDefault (Test )
103
- // TODO: parallel testing is something we should test.
102
+ SetDefault (TestFull )
104
103
}
105
104
testers .Tx (func (m testersMap ) {
106
105
rid := goid ()
Original file line number Diff line number Diff line change @@ -112,7 +112,6 @@ func (o *Result) Handle(a ...any) *Result {
112
112
o .Err = fmt .Errorf (f + wrapStr (), append (a [1 :], o .Err )... )
113
113
case ErrFn :
114
114
o .Err = f (o .Err )
115
- panic (o .Err )
116
115
case error :
117
116
if len (a ) == 2 {
118
117
hfn , haveHandlerFn := a [1 ].(ErrFn )
Original file line number Diff line number Diff line change @@ -107,6 +107,26 @@ func TestResult2_Logf(t *testing.T) {
107
107
test .RequireEqual (t , num2 , 2 )
108
108
}
109
109
110
+ func TestResult_Handle (t * testing.T ) {
111
+ // try out f() |err| handle to show how to stop propagate error
112
+ callFn := func (mode int ) (err error ) {
113
+ defer err2 .Handle (& err )
114
+
115
+ try .Out (fmt .Errorf ("test error" )).Handle (func (err error ) error {
116
+ if mode == 0 {
117
+ return err
118
+ }
119
+ return nil // no error to throw
120
+ })
121
+ return nil
122
+ }
123
+ err := callFn (1 )
124
+ test .Requiref (t , err == nil , "no error when Out.Handle sets it nil" )
125
+
126
+ err = callFn (0 )
127
+ test .Requiref (t , err != nil , "want error when Out.Handle sets it the same" )
128
+ }
129
+
110
130
func ExampleResult1_Handle () {
111
131
// try out f() |err| handle to show power of error handling language, EHL
112
132
callRead := func (in io.Reader , b []byte ) (eof bool , n int ) {
You can’t perform that action at this time.
0 commit comments