Skip to content

Commit

Permalink
Report original arg value if it was shrunk.
Browse files Browse the repository at this point in the history
  • Loading branch information
dangerousben committed Jul 27, 2019
1 parent ff6da56 commit 684ccde
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,22 +322,22 @@ object CheckerAsserting extends ExpectationCheckerAsserting {
//
// Passes 0 as verbosity value to prettyArg function.
//
private[scalacheck] def decorateArgToStringValue(arg: Arg[_], prettifier: Prettifier): String =
arg.arg match {
case null => decorateToStringValue(prettifier, arg.arg)
case _: Unit => decorateToStringValue(prettifier, arg.arg)
case _: String => decorateToStringValue(prettifier, arg.arg)
case _: Char => decorateToStringValue(prettifier, arg.arg)
case _: Array[_] => decorateToStringValue(prettifier, arg.arg)
case _ => arg.prettyArg(new Pretty.Params(0))
private[scalacheck] def decorateArgToStringValue[T](arg: T, prettyArg: Pretty, prettifier: Prettifier): String =
arg match {
case null => decorateToStringValue(prettifier, arg)
case _: Unit => decorateToStringValue(prettifier, arg)
case _: String => decorateToStringValue(prettifier, arg)
case _: Char => decorateToStringValue(prettifier, arg)
case _: Array[_] => decorateToStringValue(prettifier, arg)
case _ => prettyArg(new Pretty.Params(0))
}

private[scalacheck] def prettyArgs(args: List[Arg[_]], prettifier: Prettifier) = {
val strs = for((a, i) <- args.zipWithIndex) yield (
" " +
(if (a.label == "") "arg" + i else a.label) +
" = " + decorateArgToStringValue(a, prettifier) + (if (i < args.length - 1) "," else "") +
(if (a.shrinks > 0) " // " + a.shrinks + (if (a.shrinks == 1) " shrink" else " shrinks") else "")
" = " + decorateArgToStringValue(a.arg, a.prettyArg, prettifier) + (if (i < args.length - 1) "," else "") +
(if (a.shrinks > 0) " // " + a.shrinks + (if (a.shrinks == 1) " shrink" else " shrinks") + " (orig: " + decorateArgToStringValue(a.origArg, a.prettyOrigArg, prettifier) + ")" else "")
)
strs.mkString("\n")
}
Expand Down

0 comments on commit 684ccde

Please sign in to comment.