doctest-0.4.0: Test interactive Haskell examples

Test.DocTest

Description

An experimental API for extracting and executing DocTests.

Use getDocTests to extract DocTest examples from Haddock comments. To verify that the examples work turn them into Test.HUnit.Assertions, using withInterpreter and toAssertion. After this just wrap the newly minted assertions into something suitable for your favorite test framework.

Synopsis

Documentation

data DocTest Source

Instances

getDocTestsSource

Arguments

:: [Flag]

List of Haddock flags

-> [String]

File or module names

-> IO [DocTest]

Extracted DocTests

Extract DocTests 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.

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.

withInterpreterSource

Arguments

:: [String]

List of flags, passed to GHC

-> (Interpreter -> IO a)

Action to run

-> IO a

Result of action