diff --git a/project/MimaSettings.scala b/project/MimaSettings.scala index d094ec82c..432e77db4 100644 --- a/project/MimaSettings.scala +++ b/project/MimaSettings.scala @@ -16,6 +16,9 @@ object MimaSettings { ) private def newMethods = Seq( + "org.scalacheck.commands.Commands.shrinkCommand", + "org.scalacheck.commands.Commands.shrinkSequentialCommands", + "org.scalacheck.commands.Commands.shrinkParallelCommands", ) private def removedPrivateMethods = Seq( diff --git a/src/main/scala/org/scalacheck/commands/Commands.scala b/src/main/scala/org/scalacheck/commands/Commands.scala index 1327de7ff..9f14b5523 100644 --- a/src/main/scala/org/scalacheck/commands/Commands.scala +++ b/src/main/scala/org/scalacheck/commands/Commands.scala @@ -262,6 +262,24 @@ trait Commands { * [[State]]. By default no shrinking is done for [[State]]. */ def shrinkState: Shrink[State] = implicitly + /** Override this to provide a custom Shrinker for your internal + * [[Command]]. By default no shrinking is done for [[Command]]. */ + def shrinkCommand: Shrink[Command] = implicitly + + /** Override this to provide a custom Shrinker of sequential [[Command]]s. + * By default, the implicit List shrinker is used with [[shrinkCommand]]. */ + def shrinkSequentialCommands: Shrink[List[Command]] = { + implicit val commandShrinker = shrinkCommand + implicitly + } + + /** Override this to provide a custom Shrinker of parallel [[Command]]s. + * By default, the implict List shrinker is used with [[shrinkCommand]]. */ + def shrinkParallelCommands: Shrink[List[List[Command]]] = { + implicit val commandShrinker = shrinkCommand + implicitly + } + // Private methods // private type Commands = List[Command] @@ -270,9 +288,12 @@ trait Commands { ) private implicit val shrinkActions: Shrink[Actions] = Shrink[Actions] { as => + val shrinkSeq = shrinkSequentialCommands + val shrinkPar = shrinkParallelCommands + val shrinkedCmds: Stream[Actions] = - Shrink.shrink(as.seqCmds).map(cs => as.copy(seqCmds = cs)) append - Shrink.shrink(as.parCmds).map(cs => as.copy(parCmds = cs)) + shrinkSeq.shrink(as.seqCmds).map(cs => as.copy(seqCmds = cs)) append + shrinkPar.shrink(as.parCmds).map(cs => as.copy(parCmds = cs)) Shrink.shrinkWithOrig[State](as.s)(shrinkState) flatMap { state => shrinkedCmds.map(_.copy(s = state))