typelevel / scalacheck

Property-based testing for Scala
http://www.scalacheck.org
BSD 3-Clause "New" or "Revised" License
1.94k stars 405 forks source link

API doc for Gen.listOfN is misleading #1059

Closed kneisslm closed 2 months ago

kneisslm commented 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)

satorg commented 2 months ago

Related discussion, just for reference: #844.