An experimental API for extracting and executing DocTest
s.
Use getDocTests
to extract DocTest
examples from Haddock comments. To
verify that the examples work turn them into Test.HUnit.Assertion
s, using
withInterpreter
and toAssertion
. After this just wrap the newly minted
assertions into something suitable for your favorite test framework.
- data DocTest
- getDocTests :: [Flag] -> [String] -> IO [DocTest]
- sourcePath :: DocTest -> FilePath
- firstExpression :: DocTest -> String
- toAssertion :: Interpreter -> DocTest -> Assertion
- data Interpreter
- withInterpreter :: [String] -> (Interpreter -> IO a) -> IO a
Documentation
Extract DocTest
s from all given modules and all modules included by the
given modules.
Note that this function can be called only once during process lifetime, so use it wisely.
sourcePath :: DocTest -> FilePathSource
toAssertion :: Interpreter -> DocTest -> AssertionSource
Execute all expressions from given DocTest
in given
Interpreter
and verify the output.
The interpreter state is zeroed with :reload
before executing the
expressions. This means that you can reuse the same
Interpreter
for several calls to toAssertion
.
data Interpreter Source
:: [String] | List of flags, passed to GHC |
-> (Interpreter -> IO a) | Action to run |
-> IO a | Result of action |