Closed kneisslm closed 2 months ago
It is easy to mistake Gen.listOfN as a function that generate Lists of 0..n elements. This is not the case.
The API documentation for Gen.listOfN states that it "Generates a list with at most the given number of elements. […]" (emphasis by me).
The property check for it checks that it generates exactly n elements.
property("listOfN") = forAll(choose(0, 100)) { n => forAll(listOfN(n, arbitrary[Int])) { _.length == n } }
(GenSpecification.scala)
Related discussion, just for reference: #844.
It is easy to mistake Gen.listOfN as a function that generate Lists of 0..n elements. This is not the case.
The API documentation for Gen.listOfN states that it "Generates a list with at most the given number of elements. […]" (emphasis by me).
The property check for it checks that it generates exactly n elements.
(GenSpecification.scala)