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 working on the PR for #129, I encountered # TODO: test shrinking at the top of the StreamDataTest module.
Since there is no open issue for it, it seemed like a good idea to open it so it is not forgotten, we can discuss how this might be approached, and maybe someone can contribute a PR.
One approach might be to add a function StreamData.shrink([max_shrinking_steps: 100, initial_seed: :os.timestamp()]).
Its implementation might look like follows:
defshrink(options)whenis_list(options)domax_shrinking_steps=Keyword.get(options,:max_shrinking_steps,100)initial_seed=Keyword.get(options,:initial_seed,:os.timestamp())# Or obtained from ExUnitProperties if set during a test run.{:error,%{shrunk_value: value}}=check_all(StreamData.integer(),[max_shrinking_steps: max_shrinking_steps,initial_seed: initial_seed],&{:error,&1})valueend
(Side note: If desired, it might be optimized somewhat by instead hooking into the internals of StreamData.check_all/3 rather than calling it from the outside.)
This could then be used in a higher-order property test (a property test which builds and tests a generator).
An example:
describe"integer/1"doproperty"shrinks towards smallest value still in range"docheckallbound1<-integer(),bound2<-integer()dogenerator=integer(bound1..bound2)assertshrink(generator)==min(bound1,bound2)endendend
The text was updated successfully, but these errors were encountered:
@CoderDennis this is to add tests to code that already does shrinking. Right now, we do shrinking, but we don't really have automated tests that check that the shrinking behavior is correct.
While working on the PR for #129, I encountered
# TODO: test shrinking
at the top of theStreamDataTest
module.Since there is no open issue for it, it seemed like a good idea to open it so it is not forgotten, we can discuss how this might be approached, and maybe someone can contribute a PR.
One approach might be to add a function
StreamData.shrink([max_shrinking_steps: 100, initial_seed: :os.timestamp()])
.Its implementation might look like follows:
(Side note: If desired, it might be optimized somewhat by instead hooking into the internals of
StreamData.check_all/3
rather than calling it from the outside.)This could then be used in a higher-order property test (a property test which builds and tests a generator).
An example:
The text was updated successfully, but these errors were encountered: