Skip to content

Commit 1cd8bba

Browse files
prettier printing
1 parent e4a2672 commit 1cd8bba

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,26 +149,29 @@ runParActions pas = do
149149
joinB <- run $ forkThread $ runTracing env (threadBActions pas)
150150
(trA, _) <- run joinA
151151
(trB, _) <- run joinB
152-
monitor $ counterexample "-- Monitoring main thread"
153-
monitorTrace mempty trC
154-
monitor $ counterexample "-- Monitoring thread A"
155-
monitorTrace env trA
156-
monitor $ counterexample "-- Monitoring thread B"
157-
monitorTrace env trB
152+
let used = varsUsedInActions $ linearActions pas
153+
monitor $ counterexample "-- Main thread:"
154+
monitorTrace used mempty trC
155+
monitor $ counterexample "\n-- Thread A:"
156+
monitorTrace used env trA
157+
monitor $ counterexample "\n-- Thread B:"
158+
monitorTrace used env trB
158159
let ilvs = prepend trC $ interleavings trA trB
159160
monitor $ tabulate "TraceTree size" (map (bucket . length) ilvs)
160161
assert $ null ilvs || any (checkTrace initialAnnotatedState mempty) ilvs
161162
-- TODO: stats collection and cleanup
162163

163164
monitorTrace :: forall state m. (StateModel state, RunModelPar state m)
164-
=> Env -> Trace state m -> PropertyM m ()
165-
monitorTrace _env [] = pure ()
166-
monitorTrace env (TraceStep r v act : tr) = do
165+
=> VarContext -> Env -> Trace state m -> PropertyM m ()
166+
monitorTrace _used _env [] = pure ()
167+
monitorTrace used env (TraceStep r v act : tr) = do
167168
let showR (Right x) = show x
168169
showR (Left err) = "fail " ++ showsPrec 10 err ""
169-
monitor $ counterexample (showR r ++ " <- " ++ show (polarAction act))
170+
pre | v `wellTypedIn` used = show v ++ " @ "
171+
| otherwise = ""
172+
monitor $ counterexample (pre ++ showR r ++ " <- " ++ show (polarAction act))
170173
monitor $ monitoringPar @state @m (polarAction act) (lookUpVar env) r
171-
monitorTrace env' tr
174+
monitorTrace used env' tr
172175
where
173176
env' | Right val <- r = (v :== val) : env
174177
| otherwise = env

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module Test.QuickCheck.StateModel (
4949
performResultToEither,
5050
bucket,
5151
actionWithPolarity,
52-
52+
varsUsedInActions,
5353
) where
5454

5555
import Control.Monad
@@ -356,11 +356,11 @@ instance StateModel state => Show (Actions state) where
356356

357357
showWithUsed :: StateModel state => VarContext -> Actions state -> String
358358
showWithUsed ctx (Actions as) =
359-
let as' = WithUsedVars (combineContexts ctx $ usedVariables (Actions as)) <$> as
359+
let as' = WithUsedVars (combineContexts ctx $ varsUsedInActions (Actions as)) <$> as
360360
in intercalate "\n" $ zipWith (++) ("do " : repeat " ") (map show as' ++ ["pure ()" | null as'])
361361

362-
usedVariables :: forall state. StateModel state => Actions state -> VarContext
363-
usedVariables (Actions as) = go initialAnnotatedState as
362+
varsUsedInActions :: forall state. StateModel state => Actions state -> VarContext
363+
varsUsedInActions (Actions as) = go initialAnnotatedState as
364364
where
365365
go :: Annotated state -> [Step state] -> VarContext
366366
go aState [] = allVariables (underlyingState aState)

quickcheck-dynamic/test/Spec/DynamicLogic/RegistryModel.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,5 +347,5 @@ tests =
347347
, testProperty "moreActions 10 $ prop_Registry" $ moreActions 10 $ prop_Registry
348348
, testProperty "canRegister" $ propDL canRegister
349349
, testProperty "canRegisterNoUnregister" $ expectFailure $ propDL canRegisterNoUnregister
350-
, testProperty "prop_parRegistryIOSimPor" $ withMaxSuccess 300 $ expectFailure prop_parRegistryIOSimPor
350+
, testProperty "prop_parRegistryIOSimPor" $ expectFailure $ withMaxSuccess 1000 $ prop_parRegistryIOSimPor
351351
]

0 commit comments

Comments
 (0)