typelevel / scalacheck

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

Make buildableOf* behave more lazily #127

Closed ajknoll closed 3 years ago

ajknoll commented 9 years ago

buildableOfN currently uses Traversable.fill to build collections. Unfortunately, Traversable.fill eagerly generates the structure, which gets very expensive when generating deeply nested structures of unbounded size.

Optimally, element evaluation should be deferred until the element is requested so that nested structures are only created if they are actually inspected. It won't help with constrained generators, but it would be a useful optimisation for unconstrained generators.

ashawley commented 3 years ago

Thanks for the bug report. This was likely resolved when Gen.buildableOfN was refactored as part of #575.