Maintainer | Brandon Chinn <brandon@leapyear.io> |
---|---|
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
This module defines utilites for testing Template Haskell code.
Synopsis
- data QState (mode :: MockedMode) = QState {}
- data MockedMode
- data QMode (mode :: MockedMode) where
- data ReifyInfo = ReifyInfo {}
- loadNames :: [Name] -> ExpQ
- unmockedState :: QState NotMocked
- runTestQ :: forall mode a. IsMockedMode mode => QState mode -> Q a -> TestQResult mode a
- runTestQErr :: forall mode a. (IsMockedMode mode, Show a) => QState mode -> Q a -> TestQResult mode String
- tryTestQ :: forall mode a. IsMockedMode mode => QState mode -> Q a -> TestQResult mode (Either String a)
Configuring TestQ
data QState (mode :: MockedMode) Source #
State information for mocking Q functionality.
QState | |
|
data QMode (mode :: MockedMode) where Source #
MockQ :: QMode FullyMocked | All Q actions are mocked and IO actions are disallowed. |
MockQAllowIO :: QMode FullyMockedWithIO | Same as MockQ, except IO actions are passed through. Useful if your TH code, for example, reads files with runIO. |
AllowQ :: QMode NotMocked | No mocking is done. Useful for running Q as normal, but you need to get error messages. |
ReifyInfo | |
|
loadNames :: [Name] -> ExpQ Source #
A helper for loading names for reifyInfo
Usage:
QState { reifyInfo = $(loadNames [''Int, ''Maybe]) , ... }
unmockedState :: QState NotMocked Source #
A shortcut for defining an unmocked Q.
Running TestQ
runTestQ :: forall mode a. IsMockedMode mode => QState mode -> Q a -> TestQResult mode a Source #
runTestQErr :: forall mode a. (IsMockedMode mode, Show a) => QState mode -> Q a -> TestQResult mode String Source #
tryTestQ :: forall mode a. IsMockedMode mode => QState mode -> Q a -> TestQResult mode (Either String a) Source #