Skip to content

Commit

Permalink
brief notes on mechanics of what's going on
Browse files Browse the repository at this point in the history
  • Loading branch information
vreuter committed Oct 10, 2024
1 parent e06a642 commit 16745ff
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modules/testing/src/test/scala/TestSyntaxExtensions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ class TestSyntaxExtensions
test(
"Arbitrary.oneOf produces values of each type, in plausible relative proportions."
) {
given Arbitrary[Boolean | Int] = Arbitrary.oneOf[Boolean, Int]
/* Establish the interval for plausible counts based on Normal approximation to the Binomial. */
val n = 10000
val (lowerBound, upperBound) =
val zStar = 3.719016
val p = 0.5
val sd = scala.math.sqrt(n * p * p)
val exp = n * p
(-zStar * sd + exp, zStar * sd + exp)

// the instance under test
given Arbitrary[Boolean | Int] = Arbitrary.oneOf[Boolean, Int]

// Use the instance under test to generate the values, then count by type.
forAll(Gen.listOfN(n, arbitrary[Boolean | Int])) { values =>
val (bools, ints): (List[Boolean], List[Int]) =
Alternative[List].separate(
Expand Down

0 comments on commit 16745ff

Please sign in to comment.