From 684ccded93dcd0c13e98d579c7d244c7592ad66c Mon Sep 17 00:00:00 2001 From: Ben Spencer Date: Sat, 27 Jul 2019 15:11:48 +0100 Subject: [PATCH] Report original arg value if it was shrunk. --- .../scalacheck/CheckerAsserting.scala | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scalatestPlusScalaCheck/src/main/scala/org/scalatestplus/scalacheck/CheckerAsserting.scala b/scalatestPlusScalaCheck/src/main/scala/org/scalatestplus/scalacheck/CheckerAsserting.scala index 2afd17a..14915a1 100644 --- a/scalatestPlusScalaCheck/src/main/scala/org/scalatestplus/scalacheck/CheckerAsserting.scala +++ b/scalatestPlusScalaCheck/src/main/scala/org/scalatestplus/scalacheck/CheckerAsserting.scala @@ -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") }