Skip to content

Commit

Permalink
Shrinker.check_history now returns only the used portion of the history
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderDennis committed Feb 5, 2024
1 parent d2a041d commit d49f603
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ Copy more of the elm-test implementation. Create a `Shrinker` module.

- [ ] Add configuration option for how many times to run the test body.

- [ ] Only feed used history into next round of shrinking? Discard unused values at the end of history.
- [x] Only feed used history into next round of shrinking? Discard unused values at the end of history.
Currently, this doesn't work with the implementation of binary search, but it does work for the shrinking
by chunks.

- [ ] Implement other basic generators such as `atom`, `binary`, `string`, etc.

Expand Down
4 changes: 2 additions & 2 deletions lib/decorum/shrinker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ defmodule Decorum.Shrinker do
prng = Prng.hardcoded(history)

try do
{value, _} = generator.(prng)
{value, prng} = generator.(prng)

case check_function.(value) do
:ok -> :fail
{:error, message} -> {:pass, history, value, message}
{:error, message} -> {:pass, Prng.get_history(prng), value, message}
end
rescue
Decorum.EmptyHistoryError -> :fail
Expand Down

0 comments on commit d49f603

Please sign in to comment.