Alternative doctest implementation that extracts comments to modules
root
Known Issues
For compatibility with original
doctestparser you cannot write{-# LANGUAGE MyPreferredExtension #-}Instead you must write
:set -XMyPreferredExtensionIn Literal Haskell files only
\\begin{code} ... \\end{code}blocks are scanned, but not bird style code blocks.prop>supports multi-line code, but both originaldoctestandhaddockdo not support it.IO tests are not supported as
doctestexamples, so far. We need a syntactic distinction for IO tests, becausedoctest-extractdoes not employ a type-checker. We could mark IO tests with a specificidfunction, as inioTest $ runMyTestor a type annotation, as inrunMyTest :: IO ().
Tipps and Tricks
Interaction with editor
You may extract your doctests using the --verbose option. This emits the tested expression for before each test and it formats the source location in a way that is recognized by Emacs et.al. , i.e. you can click on the source location and thus jump to the according doctest.
How to disable selected tests?
For focussing on certain tests it can be useful to disable other ones. We have not implemented a mechanism to disable parts of the test suite in doctest-extract, because this would require to implement a way to identify tests. You can still disable some of the tests without explicit support by doctest-extraxt.
If you want to disable whole modules, you may make a copy of the auto-generated
Test/Main.hsand remove the modules that you want to skip.For disabling all tests on a function you may turn a Haddock comment into a plain comment by removing the bar after the opening of the comment.
For disabling individual tests you may prefix
>>>andprop>with an asterisk or the like.
These tricks work best in conjunction with a revision control systen, such that it always reminds you that there are tests disabled temporarily.