doctest-0.6.1: Test interactive Haskell examples

Safe HaskellSafe-Infered

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 Assertions, using withInterpreter and toAssertion. After this just wrap the newly minted assertions into something suitable for your favorite test framework.

Synopsis

Documentation

getDocTestsSource

Arguments

:: [String]

List of GHC flags

-> [String]

File or module names

-> IO [DocTest]

Extracted DocTests

Extract DocTests from all given modules and all modules included by the given modules.

sourcePath :: DocTest -> FilePathSource

Instead of what the name suggests, this returns the module name, not the file name.

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