Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/scala/org/scalacheck/Prop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ object Prop {
try { x; false } catch { case e if c.isInstance(e) => true }

/** Collect data for presentation in test report */
@deprecated("Use Prop.forAll(t => Prop.collect(t)(...)) instead of Prop.forAll(Prop.collect(t => ...))", "1.15.0")
def collect[T, P](f: T => P)(implicit ev: P => Prop): T => Prop = t => Prop { prms =>
val prop = ev(f(t))
prop(prms).collect(t)
Expand Down
15 changes: 14 additions & 1 deletion src/test/scala/org/scalacheck/PropSpecification.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package org.scalacheck
import Prop.{
forAll, falsified, undecided, exception, passed, proved, all,
atLeastOne, sizedProp, someFailing, noneFailing, Undecided, False, True,
Exception, Proof, throws, propBoolean, secure, delay, lzy
Exception, Proof, throws, propBoolean, secure, delay, lzy, collect
}
import Gen.{ const, fail, oneOf, listOf, Parameters }

Expand Down Expand Up @@ -177,6 +177,19 @@ object PropSpecification extends Properties("Prop") {

property("lzy") = { lzy(???); proved }

property("collect(t)") = {
forAll(collect(_: Boolean)(passed))
}

/* [warn] method Prop.collect is deprecated (since 1.16.0): Use
* Prop.forAll(t => Prop.collect(t)(prop))
* instead of
* Prop.forAll(Prop.collect(prop))
*/
property("collect(t => Prop") = {
forAll(collect((_: Boolean) => passed))
}

property("Gen.Parameters.withInitialSeed is deterministic") =
forAll { (p: Prop) =>
val params = Gen.Parameters.default.withInitialSeed(999L)
Expand Down