Safe Haskell | None |
---|---|
Language | Haskell98 |
Synopsis
- crash :: HasCallStack => Text -> Test a
- note :: Text -> Test ()
- scope :: Text -> Test a -> Test a
- data Status
- data Env = Env {}
- newtype Test a = Test (ReaderT Env IO (Maybe a))
- actionAllowed :: Env -> Bool
- putResult :: Status -> ReaderT Env IO ()
- runWrap :: Env -> ReaderT Env IO (Maybe a) -> IO (Maybe a)
- combineStatus :: Status -> Status -> Status
Core
scope :: Text -> Test a -> Test a Source #
Label a test. Can be nested. A "." is placed between nested
scopes, so scope "foo" . scope "bar"
is equivalent to scope "foo.bar"
Internal
Tests are values of type Test a
, and Test
forms a monad with access to:
- repeatable randomness (the
random
andrandom'
functions for random and bounded random values, or handy specializedint
,int'
,double
,double'
, etc) - I/O (via
liftIO
orio
, which is an alias forliftIO
) - failure (via
crash
, which yields a stack trace, orfail
, which does not) - logging (via
note
,noteScoped
, ornote'
) - hierarchically-named subcomputations (under
scope
) which can be switched on and off viarunOnly
- parallelism (via
fork
) - conjunction of tests via
MonadPlus
(the<|>
operation runs both tests, even if the first test fails, and the tests function used above is justmsum
).
Using any or all of these capabilities, you assemble Test
values into a "test suite" (just another Test
value) using ordinary Haskell code, not framework magic. Notice that to generate a list of random values, we just replicateM
and forM
as usual.
Instances
Monad Test Source # | |
Functor Test Source # | |
Applicative Test Source # | |
MonadIO Test Source # | |
Defined in EasyTest.Internal | |
Alternative Test Source # | |
MonadPlus Test Source # | |
MonadReader Env Test Source # | |
IsString (Test a -> Test a) Source # | |
Defined in EasyTest.Internal fromString :: String -> Test a -> Test a # |
actionAllowed :: Env -> Bool Source #