Skip to content

Commit f56c82c

Browse files
committed
Deprecate overloaded Prop.collect
1 parent fbac06c commit f56c82c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/main/scala/org/scalacheck/Prop.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ object Prop {
451451
try { x; false } catch { case e if c.isInstance(e) => true }
452452

453453
/** Collect data for presentation in test report */
454+
@deprecated("Use Prop.forAll(t => Prop.collect(t)(...)) instead of Prop.forAll(Prop.collect(t => ...))", "1.15.0")
454455
def collect[T, P](f: T => P)(implicit ev: P => Prop): T => Prop = t => Prop { prms =>
455456
val prop = ev(f(t))
456457
prop(prms).collect(t)

src/test/scala/org/scalacheck/PropSpecification.scala

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ package org.scalacheck
1212
import Prop.{
1313
forAll, falsified, undecided, exception, passed, proved, all,
1414
atLeastOne, sizedProp, someFailing, noneFailing, Undecided, False, True,
15-
Exception, Proof, throws, propBoolean, secure, delay, lzy
15+
Exception, Proof, throws, propBoolean, secure, delay, lzy, collect
1616
}
1717
import Gen.{ const, fail, oneOf, listOf, Parameters }
1818

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

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

180+
property("collect(t)") = {
181+
forAll(collect(_: Boolean)(passed))
182+
}
183+
184+
/* [warn] method Prop.collect is deprecated (since 1.16.0): Use
185+
* Prop.forAll(t => Prop.collect(t)(prop))
186+
* instead of
187+
* Prop.forAll(Prop.collect(prop))
188+
*/
189+
property("collect(t => Prop") = {
190+
forAll(collect((_: Boolean) => passed))
191+
}
192+
180193
property("Gen.Parameters.withInitialSeed is deterministic") =
181194
forAll { (p: Prop) =>
182195
val params = Gen.Parameters.default.withInitialSeed(999L)

0 commit comments

Comments
 (0)