You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While reviewing #245 I just realized that some of our arbitrary string generators in QCheck may have surprising shrinking behavior.
For QCheck.numeral_string this means that it may shrink to non-numeral strings:
#let t =Test.make QCheck.numeral_string (funn -> n <>""&&5< int_of_string n);;
valt : QCheck.Test.t=QCheck2.Test.Test<abstr>#QCheck.Test.check_exnt;;
Exception:
test `anon_test_4` raisedexception`Failure("int_of_string")`
on `"a" (after19shrinksteps)`
#
This is a consequence of how string_gen and string_gen_of_size falls back on a generic Shrink.string
Generators numeral_string and numeral_string_of_size are definitely affected.
I suspect that printable_stringprintable_string_of_size, and small_printable_string may also shrink to strings with non-printable characters under the right conditions.
The text was updated successfully, but these errors were encountered:
adding an optional shrink argument, with default to the present value so that we don't beak backward compatibility, to Shrink.string, string_gen_of_size and string_gen so that we can fix numeral_string and the others
add a parameterized string shrinker (that takes a char shrinker as argument), a string_gen_of_size_with_shrinker and a string_gen_with_shrinker that we will use in the functions we want to fix.
1 is less code but modifies an existing signature in the api while 2 is more code but does not modify existing signature (we can decide whether to add the new ones or not).
While reviewing #245 I just realized that some of our
arbitrary string
generators inQCheck
may have surprising shrinking behavior.For
QCheck.numeral_string
this means that it may shrink to non-numeral strings:This is a consequence of how
string_gen
andstring_gen_of_size
falls back on a genericShrink.string
qcheck/src/core/QCheck.ml
Lines 1112 to 1128 in fa6481f
Generators
numeral_string
andnumeral_string_of_size
are definitely affected.I suspect that
printable_string
printable_string_of_size
, andsmall_printable_string
may also shrink to strings with non-printable characters under the right conditions.The text was updated successfully, but these errors were encountered: