by mjw1007 · 1y ago · 0 comments
Suppose I have a function which takes four string parameters, and I have a bug which means it crashes if the third is empty.
I'd rather see this in the failure report:
("ldiuhuh!skdfh", "nd#lkgjdflkgdfg", "", "dc9ofugdl ifugidlugfoidufog")
than this:
("", "", "", "")
> ("ldiuhuh!skdfh", "nd#lkgjdflkgdfg", "", "dc9ofugdl ifugidlugfoidufog")
I would prefer LazySmallcheck's result, which would be the following:
(_, _, "", _)
Where `_` indicates that part of the input wasn't evaluated.So I think it would be a decent quality-of-life improvement to make generators of the sort you suggest easily available, and have the tutorial docs use them from the start.
Maybe an alternative shrinking procedure could directly minimize the number of instructions that need to be executed to hit a failure...
I agree that non-empty strings are worse, but unfortunately `("", "", "", "")` wouldn't only make me think of empty strings; e.g. I'd wonder whether duplicate/equal values are the problem.
I guess if we were even more clever we could get to something more like (…, …, "", …).
fails_on_empty_third_arg(
a = "", # or any other generated value
b = "", # or any other generated value
c = "",
d = "", # or any other generated value
)
[1] https://hypothesis.readthedocs.io/en/latest/reference/api.ht...