sydtest-0.4.0.0: A modern testing framework for Haskell with good defaults and advanced testing features.
Safe HaskellNone
LanguageHaskell2010

Test.Syd.Def.SetupFunc

Description

The SetupFunc abstraction makes resource provider functions (of type (a -> IO r) -> IO r) composable.

Synopsis

Creating SetupFuncs

newtype SetupFunc resource Source #

A function that can provide a resource.

You can think of this as a potentially-resource-aware version of 'IO resource'. In other words, it's like an 'IO resource' that can clean up after itself.

This type has a monad instance, which means you can now compose setup functions using regular do-notation. This works together nicely with most supplier functions. Some examples:

Note that these examples already have functions defined for them in sydtest companion libraries.

Constructors

SetupFunc 

Fields

Instances

Instances details
Monad SetupFunc Source # 
Instance details

Defined in Test.Syd.Def.SetupFunc

Methods

(>>=) :: SetupFunc a -> (a -> SetupFunc b) -> SetupFunc b #

(>>) :: SetupFunc a -> SetupFunc b -> SetupFunc b #

return :: a -> SetupFunc a #

Functor SetupFunc Source # 
Instance details

Defined in Test.Syd.Def.SetupFunc

Methods

fmap :: (a -> b) -> SetupFunc a -> SetupFunc b #

(<$) :: a -> SetupFunc b -> SetupFunc a #

Applicative SetupFunc Source # 
Instance details

Defined in Test.Syd.Def.SetupFunc

Methods

pure :: a -> SetupFunc a #

(<*>) :: SetupFunc (a -> b) -> SetupFunc a -> SetupFunc b #

liftA2 :: (a -> b -> c) -> SetupFunc a -> SetupFunc b -> SetupFunc c #

(*>) :: SetupFunc a -> SetupFunc b -> SetupFunc b #

(<*) :: SetupFunc a -> SetupFunc b -> SetupFunc a #

MonadIO SetupFunc Source # 
Instance details

Defined in Test.Syd.Def.SetupFunc

Methods

liftIO :: IO a -> SetupFunc a #

bracketSetupFunc :: IO resource -> (resource -> IO r) -> SetupFunc resource Source #

Turn the arguments that you would normally give to bracket into a SetupFunc.

Using SetupFunc to define your test suite

setupAround :: SetupFunc inner -> TestDefM outers inner result -> TestDefM outers () result Source #

Use around with a SetupFunc

setupAroundWith :: (oldInner -> SetupFunc newInner) -> TestDefM outers newInner result -> TestDefM outers oldInner result Source #

setupAroundWith' :: HContains outers outer => (outer -> oldInner -> SetupFunc newInner) -> TestDefM outers newInner result -> TestDefM outers oldInner result Source #

setupAroundAll :: SetupFunc outer -> TestDefM (outer ': outers) inner result -> TestDefM outers inner result Source #

Use aroundAll with a SetupFunc

setupAroundAllWith :: (oldOuter -> SetupFunc newOuter) -> TestDefM (newOuter ': (oldOuter ': outers)) inner result -> TestDefM (oldOuter ': outers) inner result Source #