test-check

alexmiller 2017-05-23T17:12:41.804183Z

@gfredericks hey, I have a probably too broad question re test.check generators. There are a number of circumstances where random inputs can get “too big” (usually via either collection sizing or nesting) if you do enough tests. Surely this is an issue that quickcheck has already encountered - do they have generic ways to do thinning or something else? (I will do some of my own research but figured you might already know about it)

2017-05-23T17:56:43.740758Z

@alexmiller you're asking about something more sophisticated than the normal size control techniques?

alexmiller 2017-05-23T17:58:47.786110Z

well… kind of. this is really about controlling size at a higher level, which as I’ve been thinking about it more is really connected to controlling generation over a greater composite structure (which is the thing we’re producing out of a composite spec)

alexmiller 2017-05-23T17:59:14.795814Z

I went and looked at some of the quickcheck stuff more and it seems like there are all those knobs for size, scale, etc

alexmiller 2017-05-23T17:59:21.798423Z

but they assume pretty localized and intentional use

alexmiller 2017-05-23T18:00:45.830976Z

my real goal here is: how can we assure that an automatically created composite generator does not produce a value so big that it kills testing. and maybe the answer is really being smarter in spec about how we use test.check

alexmiller 2017-05-23T18:01:56.858312Z

some more specific problem areas are: collection size, recursive/nesting size, and individual value size (for things that use variable memory like strings, keywords, symbols)

alexmiller 2017-05-23T18:02:32.872145Z

really these are mostly easy to manage in isolation but are in some cases harder in combination

alexmiller 2017-05-23T18:03:03.883894Z

sorry, stepping away for a few

2017-05-23T18:05:07.929638Z

Yes definitely; sizing is one of the biggest headaches I've encountered in maintaining test.check -- I've kept wanting to redo the size parameter so that it has some kind of linear relationship to the (comp count pr-str) of the value generated

2017-05-23T18:08:49.009158Z

I thought about maybe having each generator have knowledge about the size of things it generates, but that doesn't work so well for gen/one-of or gen/frequency, and not at all for gen/bind

2017-05-23T18:08:53.010575Z

even gen/fmap would be hard

2017-05-23T18:09:37.026133Z

so I think the only other approach to a general solution would be to have some sort of logical post-processing that prunes things when the whole structure is too big

2017-05-23T18:09:41.027794Z

I haven't thought about that one too much

2017-05-23T18:10:51.052243Z

My guess is that this is the biggest sizing pitfall for spec: https://dev.clojure.org/jira/browse/TCHECK-106

2017-05-23T18:11:55.074808Z

it's possible that solving that would be enough from spec's perspective

alexmiller 2017-05-23T19:22:20.544721Z

yes, I think that is the highest priority issue

alexmiller 2017-05-23T19:22:58.556990Z

Rich suggested that maybe there was some notion of “thinning” that could be applied as you generate - reducing the scale as you get deeper in a structure

2017-05-23T19:25:12.599663Z

@alexmiller yeah, that's something that the recursive-gen already does (else it'd likely generate infinite structures)

2017-05-23T19:26:17.620889Z

I certainly considered it -- it had the feel of a breaking change, so I was probably hesitant on that count, but there might have been some more subtleties; I'll give that some more thought and try it out

2017-05-23T19:27:02.635572Z

one approach I tried with recursive-gen was to take the current size and partition it up randomly among the elements of the collection to be generated

2017-05-23T19:27:14.639503Z

I think that's a lot harder with recursive-gen than it would be with the regular collection generators

2017-05-23T19:27:20.641485Z

so maybe there is hope

alexmiller 2017-05-23T19:28:43.668430Z

yeah, I saw some interesting stuff in the quickcheck papers about the recursive gen aspects

alexmiller 2017-05-23T19:29:07.676532Z

and spec is doing some of its own things there as well

2017-05-23T19:29:33.685278Z

yeah I noticed that and wasn't sure what I thought about it

alexmiller 2017-05-23T19:30:41.708639Z

heh

2017-05-23T19:30:44.709723Z

I'm not sure that there are any serious backwards-compatibility concerns about changing the sizing behavior, so I'll consider this a plausible solution

2017-05-23T19:30:59.714850Z

do you have a guess about whether there will be other serious sizing issues remaining?

alexmiller 2017-05-23T19:31:23.722939Z

collection size and recursion seem to be at the root of the majority of issues I see

2017-05-23T19:31:44.729862Z

does spec use recursive-gen at all?

alexmiller 2017-05-23T19:31:55.733403Z

don’t know

2017-05-23T19:32:03.736032Z

I think the biggest thing I noticed was that it didn't even with naturally recursive specs

alexmiller 2017-05-23T19:32:43.749128Z

yeah, the gen namespace doesn’t pull in recursive-gen so I’d guess nothing is using it

2017-05-23T19:32:56.753397Z

it might not be a good fit anyhow

alexmiller 2017-05-23T19:33:14.759302Z

I don’t know if that was a conscious choice or not (although with Rich I typically bet on the side of conscious choice)

alexmiller 2017-05-23T19:33:43.768590Z

stepping away again, maybe for a while, sorry :)

2017-05-23T19:33:54.772017Z

no problem