Skip to content

Commit 19eda90

Browse files
committed
Add runActionsFrom
Allow running the action sequence from a user supplied initial state
1 parent 071092c commit 19eda90

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

quickcheck-dynamic/src/Test/QuickCheck/StateModel.hs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module Test.QuickCheck.StateModel (
3131
monitorPost,
3232
counterexamplePost,
3333
stateAfter,
34+
runActionsFrom,
3435
runActions,
3536
lookUpVar,
3637
lookUpVarMaybe,
@@ -548,7 +549,19 @@ runActions
548549
)
549550
=> Actions state
550551
-> PropertyM m (Annotated state, Env)
551-
runActions (Actions_ rejected (Smart _ actions)) = do
552+
runActions = runActionsFrom initialAnnotatedState
553+
554+
runActionsFrom
555+
:: forall state m e
556+
. ( StateModel state
557+
, RunModel state m
558+
, e ~ Error state m
559+
, forall a. IsPerformResult e a
560+
)
561+
=> Annotated state
562+
-> Actions state
563+
-> PropertyM m (Annotated state, Env)
564+
runActionsFrom annotatedState (Actions_ rejected (Smart _ actions)) = do
552565
let bucket = \n -> let (a, b) = go n in show a ++ " - " ++ show b
553566
where
554567
go n
@@ -557,7 +570,7 @@ runActions (Actions_ rejected (Smart _ actions)) = do
557570
where
558571
d = div n 10
559572
monitor $ tabulate "# of actions" [show $ bucket $ length actions]
560-
(finalState, env, names, polars) <- runSteps initialAnnotatedState [] actions
573+
(finalState, env, names, polars) <- runSteps annotatedState [] actions
561574
monitor $ tabulate "Actions" names
562575
monitor $ tabulate "Action polarity" $ map show polars
563576
unless (null rejected) $

0 commit comments

Comments
 (0)