File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed
quickcheck-dynamic/src/Test/QuickCheck Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -133,13 +133,16 @@ forAllNonVariableQ q = DL $ \s k -> DL.forAllQ (hasNoVariablesQ q) $ \(HasNoVari
133133runDL :: Annotated s -> DL s () -> DL. DynFormula s
134134runDL 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+
136139forAllUniqueDL
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
144147forAllDL
145148 :: (DL. DynLogicModel s , Testable a )
Original file line number Diff line number Diff line change @@ -355,6 +355,7 @@ restrictedPolar (ActionWithPolarity a _) = restricted a
355355forAllScripts
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.
364365forAllUniqueScripts
365366 :: (DynLogicModel s , Testable a )
366- => Annotated s
367+ => s
368+ -- ^ The initial state
367369 -> DynFormula s
368370 -> (Actions s -> a )
369371 -> Property
370372forAllUniqueScripts 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
478480sizeLimit :: Int -> Int
You can’t perform that action at this time.
0 commit comments