Skip to content

Commit

Permalink
Merge pull request #497 from ashawley/improve-param-errors
Browse files Browse the repository at this point in the history
Improve errors for test parameters
  • Loading branch information
non authored Aug 7, 2019
2 parents aaffe1e + 0315fec commit ce0e23e
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/main/scala/org/scalacheck/Test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,21 @@ object Test {
}

private def assertParams(prms: Parameters) = {
import prms._
if(
minSuccessfulTests <= 0 ||
maxDiscardRatio <= 0 ||
minSize < 0 ||
maxSize < minSize ||
workers <= 0
) throw new IllegalArgumentException("Invalid test parameters")
if (prms.minSuccessfulTests <= 0)
throw new IllegalArgumentException(
s"Invalid test parameter: minSuccessfulTests (${prms.minSuccessfulTests}) <= 0")
else if (prms.maxDiscardRatio <= 0)
throw new IllegalArgumentException(
s"Invalid test parameter: maxDiscardRatio (${prms.maxDiscardRatio}) <= 0")
else if (prms.minSize < 0)
throw new IllegalArgumentException(
s"Invalid test parameter: minSize (${prms.minSize}) < 0")
else if (prms.maxSize < prms.minSize)
throw new IllegalArgumentException(
s"Invalid test parameter: maxSize (${prms.maxSize}) < minSize (${prms.minSize})")
else if (prms.workers <= 0)
throw new IllegalArgumentException(
s"Invalid test parameter: workers (${prms.workers}) <= 0")
}

private[scalacheck] lazy val cmdLineParser = new CmdLineParser {
Expand Down

0 comments on commit ce0e23e

Please sign in to comment.