Skip to content

Commit

Permalink
Merge pull request sbt#333 from ashawley/gen-pick-defect
Browse files Browse the repository at this point in the history
Gen.pick defect
  • Loading branch information
rickynils authored Jul 13, 2017
2 parents 3f7ef62 + 2ee295d commit db2a1fc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions jvm/src/test/scala/org/scalacheck/GenSpecification.scala
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,18 @@ object GenSpecification extends Properties("Gen") {
}
}

property("distributed pick") = {
val lst = (0 to 7).toIterable
val n = 2
forAll(pick(n, lst)) { xs: Seq[Int] =>
xs.map { x: Int =>
Prop.collect(x) {
xs.size == n
}
} reduce (_ && _)
}
}

property("numChar") = forAll(numChar)(_.isDigit)

property("calendar") = forAll(calendar) { cal =>
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/org/scalacheck/Gen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ object Gen extends GenArities{
buf += t
} else {
val (x, s) = seed.long
val i = (x & 0x7fffffff).toInt % n
val i = (x & 0x7fffffff).toInt % count
if (i < n) buf(i) = t
seed = s
}
Expand Down

0 comments on commit db2a1fc

Please sign in to comment.