Safe Haskell | None |
---|---|
Language | Haskell2010 |
The SetupFunc
abstraction makes resource provider functions (of type (a -> IO r) -> IO r
) composable.
Synopsis
- newtype SetupFunc resource = SetupFunc {
- unSetupFunc :: forall r. (resource -> IO r) -> IO r
- bracketSetupFunc :: IO resource -> (resource -> IO r) -> SetupFunc resource
- setupAround :: SetupFunc inner -> TestDefM outers inner result -> TestDefM outers () result
- setupAroundWith :: (oldInner -> SetupFunc newInner) -> TestDefM outers newInner result -> TestDefM outers oldInner result
- setupAroundWith' :: HContains outers outer => (outer -> oldInner -> SetupFunc newInner) -> TestDefM outers newInner result -> TestDefM outers oldInner result
- setupAroundAll :: SetupFunc outer -> TestDefM (outer ': outers) inner result -> TestDefM outers inner result
- setupAroundAllWith :: (oldOuter -> SetupFunc newOuter) -> TestDefM (newOuter ': (oldOuter ': outers)) inner result -> TestDefM (oldOuter ': outers) inner result
Creating SetupFunc
s
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.
SetupFunc | |
|
Using SetupFunc
to define your test suite
setupAround :: SetupFunc inner -> TestDefM outers inner result -> TestDefM outers () result Source #
setupAroundWith :: (oldInner -> SetupFunc newInner) -> TestDefM outers newInner result -> TestDefM outers oldInner result Source #
Use aroundWith
with a SetupFunc
setupAroundWith' :: HContains outers outer => (outer -> oldInner -> SetupFunc newInner) -> TestDefM outers newInner result -> TestDefM outers oldInner result Source #
Use aroundWith'
with a SetupFunc
setupAroundAll :: SetupFunc outer -> TestDefM (outer ': outers) inner result -> TestDefM outers inner result Source #
setupAroundAllWith :: (oldOuter -> SetupFunc newOuter) -> TestDefM (newOuter ': (oldOuter ': outers)) inner result -> TestDefM (oldOuter ': outers) inner result Source #
Use aroundAllWith
with a SetupFunc