tests
Safe HaskellSafe-Inferred
LanguageGHC2021

Test.Util

Synopsis

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 ... @

propCollisionResistant :: (Show a, Eq a) => String -> Gen a -> Spec Source #

This creates an hspec test case about a property which ensures the given generator does not produce equals values within a reasonable number of generated values.