Skip to content

Better document/fix shrinking API #218

Closed
@sir4ur0n

Description

@sir4ur0n

Hi,

I have written a library of generators for Vavr, and I'm now addressing the shrinking part.
The shrinking API is weird and not enough documented. Here's a list of proposals:

  1. Why try bigger values before smaller values?
    See QuickCheck documentation on shrinking: it tries smaller values before bigger values, which makes more sense (don't bother testing a huge list of N-1 elements if an empty list already blows up).

  2. Support a lazy structure: doShrink must return a java.util.List which has only strict implementations in the JDK AFAIK. Building a list of shrinks may be CPU-heavy, and if the first value doesn't pass, then we discard everything and start shrinking again from the slightly smallest value.
    If we could return a lazy structure (e.g. a Stream), this would significantly improve the shrinking process.

  3. Provide an easy way to log/understand what happens during shrinking, much like QuickCheck provides a verbose mode which details every step (passed, failed, shrunk, etc.).

Passed:
[]
Passed:
[]
Passed:
[]
Failed:
[2,2]
Passed:
[]
Passed:
[2]
Passed:
[2]
Failed:
[0,2]
Passed:
[]
Passed:
[2]
Passed:
[0]
Failed:
[0,0]
Passed:
[]
Passed:
[0]
Passed:
[0]
*** Failed! Falsifiable (after 4 tests and 2 shrinks):
[0,0]
Use --quickcheck-replay=249810 to reproduce.

If it already exists, providing documentation to detail this would be nice 😄

Let me know if you want me to open several issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions