typelevel / typelevel/scalacheck
Shrinking shrinks a List required to be nonEmpty to Nil
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2k
- Forks
- 393
- Avg merge
- 6h 42m
- Merged PRs (30d)
- 4
Description
Let's have a generator of a data structure which contains a non empty list. Like
Gen.nonEmptyListOf(Gen.choose(0,10))
When shrinking kicks in, what happens is that the list gets shortened - well that's an obvious way to reduce the input, I agree. Yet if the error is caused by a different parameter, than the shrinking does not stop and shrinks the list all the way to Nil.
That kind of sucks, because there is definitely a reason for the list to be non empty! In my case it causes an empty.head error which is completely misleading and obscures the actual problem.
IMO the Shrinker should respect the domain of the values specified by the defined Generator.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with Gen.nonEmptyListOf(Gen.choose(0,10)) and inspect the Shrinker behavior when another parameter causes the property to fail. Done means shrinking reduces the list without producing Nil, preserving the non-empty domain and avoiding a misleading empty.head failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100