cats
cats copied to clipboard
replicateA_ consistency tests creates very large values
Encountered when trying to upgrade fs2 to cats 2.8.0. The Monad[Chunk] and Alternative[Chunk] laws tests fail with out of memory errors. These tests use a Gen[Chunk[Int]] with a max size of 300 elements. The new replicateA_ consistent with replicateA.void test expands that to a 300^4 collection.
https://github.com/typelevel/cats/blob/v2.8.0/laws/src/main/scala/cats/laws/discipline/ApplicativeTests.scala#L63
For now, I'll disable monad + alternative laws testing for Chunk since I don't see a straightforward way to skip that test.
So this became a problem for Chunk because it calls resize internally in its own generator.
https://github.com/armanbilge/fs2/blob/170dbd69167294b708484ed8664f5c7c7666f43d/core/shared/src/test/scala/fs2/ChunkGenerators.scala#L49-L53
This overrides the .resize(4, ...) we added specifically to try and avoid issues like this.
Workaround in https://github.com/typelevel/fs2/pull/2928/commits/bbe1f41cfecf3fa97777c4173b94a0406f17bd20. tl;dr use Gen.sized to access the current generation size and derive the resize value from that, instead of completely replacing it.