Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combinators to modify the size parameter #9

Open
graue opened this issue Aug 15, 2014 · 0 comments
Open

Combinators to modify the size parameter #9

graue opened this issue Aug 15, 2014 · 0 comments

Comments

@graue
Copy link
Owner

graue commented Aug 15, 2014

Motivation: the invisible size parameter, which ramps up from 1 to 50 (by default, controllable with --max-size) over the course of a test run, controls both array lengths and the magnitude of generated integers. This means it is not possible to, for example, generate short arrays containing large numbers (e.g. 10 integers that are all in the millions), or long arrays containing small numbers (e.g., 100,000 integers between 0 and 10).

To enable this, we need to allow something like:

t.arrayOf(t.scaleSize(5, t.int.nonNegative))

In which scaleSize(mult, gen) would delegate to gen but with the size parameter multiplied by mult.

Reading the size is useful for creating recursive structures, so we should have that too. See "A generator for bounded trees" in this QuickCheck example.

Other implementations (test.check) also have combinators to set the size to a constant amount (not a multiplier), but I am less clear on why this would be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant