Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't drop actions depending on shrunk predecessors. #453

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions hedgehog/src/Hedgehog/Internal/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,12 @@ action commands =
Command mgenInput exec callbacks <-
Gen.element_ $ filter (\c -> commandGenOK c state0) commands

-- If we shrink the input, we still want to use the same output. Otherwise
-- any actions using this output as part of their input will be dropped. But
-- the existing output is still in the context, so `contextNewVar` will
-- create a new one. To avoid that, we generate the output before the input.
output <- contextNewVar

input <-
case mgenInput state0 of
Nothing ->
Expand All @@ -559,8 +565,6 @@ action commands =
pure Nothing

else do
output <- contextNewVar

contextUpdate $
callbackUpdate callbacks state0 input (Var output)

Expand Down