From 16745ff3db65b114820f0aab2cee4dafa41523f3 Mon Sep 17 00:00:00 2001 From: Vince Reuter Date: Fri, 4 Oct 2024 20:31:38 +0200 Subject: [PATCH] brief notes on mechanics of what's going on --- modules/testing/src/test/scala/TestSyntaxExtensions.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/testing/src/test/scala/TestSyntaxExtensions.scala b/modules/testing/src/test/scala/TestSyntaxExtensions.scala index ad60f40..7df286c 100644 --- a/modules/testing/src/test/scala/TestSyntaxExtensions.scala +++ b/modules/testing/src/test/scala/TestSyntaxExtensions.scala @@ -23,7 +23,7 @@ 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 @@ -31,6 +31,11 @@ class TestSyntaxExtensions 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(