@@ -772,10 +772,13 @@ object Prop {
772
772
/*
773
773
* Returns the first failed result in Left or success in Right.
774
774
*/
775
- def getFirstFailure (xs : Stream [T ]): Either [(T ,Result ),(T ,Result )] = {
775
+ def getFirstFailure (xs : Stream [T ], exceptionFilter : Option [ Class [_]] ): Either [(T ,Result ),(T ,Result )] = {
776
776
assert(! xs.isEmpty, " Stream cannot be empty" )
777
777
val results = xs.map(x => (x, result(x)))
778
- results.dropWhile(! _._2.failure).headOption match {
778
+ results.dropWhile {
779
+ case (_, Result (Exception (e), _, _, _)) => ! exceptionFilter.contains(e.getClass)
780
+ case (_, r) => ! r.failure
781
+ }.headOption match {
779
782
case None => Right (results.head)
780
783
case Some (xr) => Left (xr)
781
784
}
@@ -784,7 +787,8 @@ object Prop {
784
787
def shrinker (x : T , r : Result , shrinks : Int , orig : T ): Result = {
785
788
val xs = shrink(x)
786
789
val res = r.addArg(Arg (labels,x,shrinks,orig,pp(x),pp(orig)))
787
- if (xs.isEmpty) res else getFirstFailure(xs) match {
790
+ val originalException = Some (r.status).collect { case Exception (e) => e.getClass() }
791
+ if (xs.isEmpty) res else getFirstFailure(xs, originalException) match {
788
792
case Right ((x2,r2)) => res
789
793
case Left ((x2,r2)) => shrinker(x2, replOrig(r,r2), shrinks+ 1 , orig)
790
794
}
0 commit comments