@@ -599,3 +599,42 @@ func (e *errWithIs) Is(o error) bool {
599599 }
600600 return false
601601}
602+
603+ func TestCompareUncomparable (t * testing.T ) {
604+ tt := testutils.T {T : t }
605+
606+ err1 := errors .New ("hello" )
607+ var nilErr error
608+ f := []string {"woo" }
609+ tt .Check (markers .Is (errorUncomparable {f }, errorUncomparable {}))
610+ tt .Check (markers .IsAny (errorUncomparable {f }, errorUncomparable {}))
611+ tt .Check (markers .IsAny (errorUncomparable {f }, nilErr , errorUncomparable {}))
612+ tt .Check (! markers .Is (errorUncomparable {f }, & errorUncomparable {}))
613+ tt .Check (! markers .IsAny (errorUncomparable {f }, & errorUncomparable {}))
614+ tt .Check (! markers .IsAny (errorUncomparable {f }, nilErr , & errorUncomparable {}))
615+ tt .Check (markers .Is (& errorUncomparable {f }, errorUncomparable {}))
616+ tt .Check (markers .IsAny (& errorUncomparable {f }, errorUncomparable {}))
617+ tt .Check (markers .IsAny (& errorUncomparable {f }, nilErr , errorUncomparable {}))
618+ tt .Check (! markers .Is (& errorUncomparable {f }, & errorUncomparable {}))
619+ tt .Check (! markers .IsAny (& errorUncomparable {f }, & errorUncomparable {}))
620+ tt .Check (! markers .IsAny (& errorUncomparable {f }, nilErr , & errorUncomparable {}))
621+ tt .Check (! markers .Is (errorUncomparable {f }, err1 ))
622+ tt .Check (! markers .IsAny (errorUncomparable {f }, err1 ))
623+ tt .Check (! markers .IsAny (errorUncomparable {f }, nilErr , err1 ))
624+ tt .Check (! markers .Is (& errorUncomparable {f }, err1 ))
625+ tt .Check (! markers .IsAny (& errorUncomparable {f }, err1 ))
626+ tt .Check (! markers .IsAny (& errorUncomparable {f }, nilErr , err1 ))
627+ }
628+
629+ type errorUncomparable struct {
630+ f []string
631+ }
632+
633+ func (e errorUncomparable ) Error () string {
634+ return fmt .Sprintf ("uncomparable error %d" , len (e .f ))
635+ }
636+
637+ func (errorUncomparable ) Is (target error ) bool {
638+ _ , ok := target .(errorUncomparable )
639+ return ok
640+ }
0 commit comments