Skip to content
Permalink
Browse files
Replaced Test.Params with Test.Parameters.
Test.Parameters is a trait instead of a case class, which will probably
make it easier to keep ScalaCheck binary compatible between releases.

Test.Params has not been rmeoved, only deprecated, so old code should
still work as before.
  • Loading branch information
rickynils committed Jul 5, 2012
1 parent b40644f commit f430413
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 62 deletions.
@@ -212,23 +212,43 @@ object Arbitrary {
))
}

/** Arbitrary instance of test params */
/** Arbitrary instance of test params
* @deprecated (in 1.10.0) Use <code>arbTestParameters</code> instead.
*/
@deprecated("Use 'arbTestParameters' instead", "1.10.0")
implicit lazy val arbTestParams: Arbitrary[Test.Params] =
Arbitrary(for {
minSuccTests <- choose(10,200)
maxDiscardRatio <- choose(0.2f,10f)
minSize <- choose(0,500)
maxDiscTests <- choose(100,500)
mnSize <- choose(0,500)
sizeDiff <- choose(0,500)
maxSize <- choose(minSize, minSize + sizeDiff)
mxSize <- choose(mnSize, mnSize + sizeDiff)
ws <- choose(1,4)
} yield Test.Params(
minSuccessfulTests = minSuccTests,
maxDiscardRatio = maxDiscardRatio,
minSize = minSize,
maxSize = maxSize,
maxDiscardedTests = maxDiscTests,
minSize = mnSize,
maxSize = mxSize,
workers = ws
))

/** Arbitrary instance of test parameters */
implicit lazy val arbTestParameters: Arbitrary[Test.Parameters] =
Arbitrary(for {
_minSuccTests <- choose(10,200)
_maxDiscardRatio <- choose(0.2f,10f)
_minSize <- choose(0,500)
sizeDiff <- choose(0,500)
_maxSize <- choose(_minSize, _minSize + sizeDiff)
_workers <- choose(1,4)
} yield new Test.Parameters.Default {
override val minSuccessfulTests = _minSuccTests
override val maxDiscardRatio = _maxDiscardRatio
override val minSize = _minSize
override val maxSize = _maxSize
override val workers = _workers
})

/** Arbitrary instance of gen params */
implicit lazy val arbGenParams: Arbitrary[Gen.Params] =
Arbitrary(for {
@@ -32,15 +32,26 @@ trait Prop {
/** Convenience method that checks this property with the given parameters
* and reports the result on the console. If you need to get the results
* from the test use the <code>check</code> methods in <code>Test</code>
* instead. */
* instead.
* @deprecated (in 1.10.0) Use <code>check(Test.Parameters)</code> instead.
*/
@deprecated("Use 'check(Test.Parameters)' instead", "1.10.0")
def check(prms: Test.Params): Unit = Test.check(
prms copy (testCallback = ConsoleReporter(1) chain prms.testCallback), this
)

/** Convenience method that checks this property with the given parameters
* and reports the result on the console. If you need to get the results
* from the test use the <code>check</code> methods in <code>Test</code>
* instead. */
def check(prms: Test.Parameters): Unit = Test.check(
prms copy (_testCallback = ConsoleReporter(1) chain prms.testCallback), this
)

/** Convenience method that checks this property and reports the
* result on the console. If you need to get the results from the test use
* the <code>check</code> methods in <code>Test</code> instead. */
def check: Unit = check(Test.Params())
def check: Unit = check(Test.Parameters.default)

/** The logic for main, separated out to make it easier to
* avoid System.exit calls. Returns exit code.
@@ -44,14 +44,25 @@ class Properties(val name: String) extends Prop {
* and reports the result on the console. If you need to get the results
* from the test use the <code>check</code> methods in <code>Test</code>
* instead. */
override def check(prms: Test.Parameters): Unit = Test.checkProperties(
prms copy (_testCallback = ConsoleReporter(1) chain prms.testCallback), this
)

/** Convenience method that checks the properties with the given parameters
* and reports the result on the console. If you need to get the results
* from the test use the <code>check</code> methods in <code>Test</code>
* instead.
* @deprecated (in 1.10.0) Use <code>check(Test.Parameters)</code> instead.
*/
@deprecated("Use 'check(Test.Parameters)' instead", "1.10.0")
override def check(prms: Test.Params): Unit = Test.checkProperties(
prms copy (testCallback = ConsoleReporter(1) chain prms.testCallback), this
)

/** Convenience method that checks the properties and reports the
* result on the console. If you need to get the results from the test use
* the <code>check</code> methods in <code>Test</code> instead. */
override def check: Unit = check(Test.Params())
override def check: Unit = check(Test.Parameters.default)

/** The logic for main, separated out to make it easier to
* avoid System.exit calls. Returns exit code.
@@ -69,7 +69,7 @@ class ScalaCheckFramework extends Framework {
import Test.cmdLineParser.{Success, NoSuccess}
val prms = Test.cmdLineParser.parseParams(args) match {
case Success(params, _) =>
params copy (testCallback = testCallback, customClassLoader = Some(loader))
params.copy(_testCallback = testCallback, _customClassLoader = Some(loader))
// TODO: Maybe handle this a bit better than throwing exception?
case e: NoSuccess => throw new Exception(e.toString)
}

0 comments on commit f430413

Please sign in to comment.