Skip to content

Commit 2781976

Browse files
Documentation + todo
1 parent 3fca82e commit 2781976

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,16 @@ forAllNonVariableQ q = DL $ \s k -> DL.forAllQ (hasNoVariablesQ q) $ \(HasNoVari
133133
runDL :: Annotated s -> DL s () -> DL.DynFormula s
134134
runDL s dl = (unDL dl s $ \_ _ -> DL.passTest)
135135

136+
-- TODO: We probably want versions of these three functions that take an `s` so that you can write DL
137+
-- properties that are only true in a specific starting state rather than a random starting state.
138+
136139
forAllUniqueDL
137140
:: (DL.DynLogicModel s, Testable a)
138-
=> Annotated s
139-
-> DL s ()
141+
=> DL s ()
140142
-> (Actions s -> a)
141143
-> Property
142-
forAllUniqueDL initState d = DL.forAllUniqueScripts initState (runDL initState d)
144+
forAllUniqueDL d p =
145+
forAllBlind initialState $ \st -> DL.forAllUniqueScripts st (runDL (Metadata mempty st) d) p
143146

144147
forAllDL
145148
:: (DL.DynLogicModel s, Testable a)

quickcheck-dynamic/src/Test/QuickCheck/DynamicLogic/Internal.hs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ restrictedPolar (ActionWithPolarity a _) = restricted a
355355
forAllScripts
356356
:: (DynLogicModel s, Testable a)
357357
=> s
358+
-- ^ The initial state
358359
-> DynFormula s
359360
-> (Actions s -> a)
360361
-> Property
@@ -363,15 +364,15 @@ forAllScripts s = forAllMappedScripts s id id
363364
-- | `Property` function suitable for formulae without choice.
364365
forAllUniqueScripts
365366
:: (DynLogicModel s, Testable a)
366-
=> Annotated s
367+
=> s
368+
-- ^ The initial state
367369
-> DynFormula s
368370
-> (Actions s -> a)
369371
-> Property
370372
forAllUniqueScripts s f k =
371373
QC.withSize $ \sz ->
372374
let d = unDynFormula f sz
373-
n = unsafeNextVarIndex $ vars s
374-
in case generate chooseUniqueNextStep d n s 500 of
375+
in case generate chooseUniqueNextStep d 1 (Metadata mempty s) 500 of
375376
Nothing -> counterexample "Generating Non-unique script in forAllUniqueScripts" False
376377
Just test -> validDLTest test . applyMonitoring d test . property $ k (scriptFromDL test)
377378

@@ -472,7 +473,8 @@ generate chooseNextStepFun d n s size =
472473
useStep NoStep alt = alt
473474
foldr
474475
(\step k -> do try <- chooseNextStepFun s n step; useStep try k)
475-
(return $ Stuck s TestSeqStop s)
476+
(return $ Stuck s TestSeqStop s) -- NOTE: we will cons on this `TestSeqStop` so the `s` will not be the same before
477+
-- and after state when we get out of this function.
476478
[preferred, noAny preferred, d, noAny d]
477479

478480
sizeLimit :: Int -> Int

0 commit comments

Comments
 (0)