Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Test.Util
Synopsis
- shouldRunInSim :: (forall s. IOSim s a) -> IO a
- printTrace :: forall log a. (Typeable log, ToJSON log) => Proxy log -> SimTrace a -> Text
- shouldBe :: (HasCallStack, MonadThrow m, Eq a, Show a) => a -> a -> m ()
- shouldReturn :: (HasCallStack, MonadThrow m, Eq a, Show a) => m a -> a -> m ()
- shouldSatisfy :: (HasCallStack, MonadThrow m, Show a) => a -> (a -> Bool) -> m ()
- shouldNotBe :: (HasCallStack, MonadThrow m, Eq a, Show a) => a -> a -> m ()
- shouldContain :: (HasCallStack, MonadThrow m, Eq a, Show a) => [a] -> [a] -> m ()
- traceInIOSim :: Typeable a => Tracer (IOSim s) a
- traceDebug :: (Applicative m, ToJSON a) => Tracer m a
- propCollisionResistant :: (Show a, Eq a) => String -> Gen a -> Spec
Documentation
shouldRunInSim :: (forall s. IOSim s a) -> IO a Source #
Run given action
in IOSim
and rethrow any exceptions.
printTrace :: forall log a. (Typeable log, ToJSON log) => Proxy log -> SimTrace a -> Text Source #
Utility function to dump logs given a SimTrace
.
shouldBe :: (HasCallStack, MonadThrow m, Eq a, Show a) => a -> a -> m () Source #
Lifted variant of Hspec's shouldBe
.
shouldReturn :: (HasCallStack, MonadThrow m, Eq a, Show a) => m a -> a -> m () Source #
Lifted variant of Hspec's shouldReturn
.
shouldSatisfy :: (HasCallStack, MonadThrow m, Show a) => a -> (a -> Bool) -> m () Source #
Lifted variant of Hspec's shouldSatisfy
.
shouldNotBe :: (HasCallStack, MonadThrow m, Eq a, Show a) => a -> a -> m () Source #
Lifted variant of Hspec's shouldNotBe
.
shouldContain :: (HasCallStack, MonadThrow m, Eq a, Show a) => [a] -> [a] -> m () Source #
Lifted variant of Hspec's shouldContain
.
traceInIOSim :: Typeable a => Tracer (IOSim s) a Source #
A Tracer
that works in IOSim
monad.
This tracer uses the Output
event which uses converts value traced to Dynamic
which requires Typeable
constraint. To retrieve the trace use selectTraceEventsDynamic
applied to the correct type.
traceDebug :: (Applicative m, ToJSON a) => Tracer m a Source #
Useful when one needs to also trace logs to stderr
.
Thanks to the monoidal nature of Tracer
it's straightforward to add this to
any existing tracer:
@
someCode tracer = do
foo <- makeFoo
withTracer (tr <> traceDebug) SomeTraceFoo
...
@