<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Test.HUnit.Base</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[ window.onload = function () {pageLoad();setSynopsis("mini_Test-HUnit-Base.html");}; //]]> </script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Test-HUnit-Base.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">HUnit-1.2.2.3: A unit testing framework for Haskell</p></div><div id="content"><div id="module-header"><p class="caption">Test.HUnit.Base</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Declaring tests </a></li><li><a href="#g:2">Making assertions </a></li><li><a href="#g:3">Extending the assertion functionality </a></li><li><a href="#g:4">Test execution </a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>Basic definitions for the HUnit library. </p><p>This module contains what you need to create assertions and test cases and combine them into test suites. </p><p>This module also provides infrastructure for implementing test controllers (which are used to execute tests). See <a href="Test-HUnit-Text.html">Test.HUnit.Text</a> for a great example of how to implement a test controller. </p></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><span class="keyword">data</span> <a href="#t:Test">Test</a> <ul class="subs"><li>= <a href="#v:TestCase">TestCase</a> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a> </li><li>| <a href="#v:TestList">TestList</a> [<a href="Test-HUnit-Base.html#t:Test">Test</a>] </li><li>| <a href="#v:TestLabel">TestLabel</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> <a href="Test-HUnit-Base.html#t:Test">Test</a> </li></ul></li><li class="src short"><a href="#v:-126--61--63-">(~=?)</a> :: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> a, <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> a) => a -> a -> <a href="Test-HUnit-Base.html#t:Test">Test</a></li><li class="src short"><a href="#v:-126--63--61-">(~?=)</a> :: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> a, <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> a) => a -> a -> <a href="Test-HUnit-Base.html#t:Test">Test</a></li><li class="src short"><a href="#v:-126-:">(~:)</a> :: <a href="Test-HUnit-Base.html#t:Testable">Testable</a> t => <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -> t -> <a href="Test-HUnit-Base.html#t:Test">Test</a></li><li class="src short"><a href="#v:-126--63-">(~?)</a> :: <a href="Test-HUnit-Base.html#t:AssertionPredicable">AssertionPredicable</a> t => t -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -> <a href="Test-HUnit-Base.html#t:Test">Test</a></li><li class="src short"><a href="#v:assertFailure">assertFailure</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></li><li class="src short"><a href="#v:assertBool">assertBool</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Bool.html#t:Bool">Bool</a> -> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></li><li class="src short"><a href="#v:assertEqual">assertEqual</a> :: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> a, <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> a) => <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -> a -> a -> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></li><li class="src short"><a href="#v:assertString">assertString</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:Assertion">Assertion</a> = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a></li><li class="src short"><a href="#v:-64--61--63-">(@=?)</a> :: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> a, <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> a) => a -> a -> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></li><li class="src short"><a href="#v:-64--63--61-">(@?=)</a> :: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> a, <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> a) => a -> a -> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></li><li class="src short"><a href="#v:-64--63-">(@?)</a> :: <a href="Test-HUnit-Base.html#t:AssertionPredicable">AssertionPredicable</a> t => t -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></li><li class="src short"><span class="keyword">class</span> <a href="#t:Assertable">Assertable</a> t <span class="keyword">where</span><ul class="subs"><li><a href="#v:assert">assert</a> :: t -> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></li></ul></li><li class="src short"><span class="keyword">class</span> <a href="#t:ListAssertable">ListAssertable</a> t <span class="keyword">where</span><ul class="subs"><li><a href="#v:listAssert">listAssert</a> :: [t] -> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></li></ul></li><li class="src short"><span class="keyword">type</span> <a href="#t:AssertionPredicate">AssertionPredicate</a> = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><span class="keyword">class</span> <a href="#t:AssertionPredicable">AssertionPredicable</a> t <span class="keyword">where</span><ul class="subs"><li><a href="#v:assertionPredicate">assertionPredicate</a> :: t -> <a href="Test-HUnit-Base.html#t:AssertionPredicate">AssertionPredicate</a></li></ul></li><li class="src short"><span class="keyword">class</span> <a href="#t:Testable">Testable</a> t <span class="keyword">where</span><ul class="subs"><li><a href="#v:test">test</a> :: t -> <a href="Test-HUnit-Base.html#t:Test">Test</a></li></ul></li><li class="src short"><span class="keyword">data</span> <a href="#t:State">State</a> = <a href="#v:State">State</a> {<ul class="subs"><li><a href="#v:path">path</a> :: <a href="Test-HUnit-Base.html#t:Path">Path</a></li><li><a href="#v:counts">counts</a> :: <a href="Test-HUnit-Base.html#t:Counts">Counts</a></li></ul>}</li><li class="src short"><span class="keyword">data</span> <a href="#t:Counts">Counts</a> = <a href="#v:Counts">Counts</a> {<ul class="subs"><li><a href="#v:cases">cases</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></li><li><a href="#v:tried">tried</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></li><li><a href="#v:errors">errors</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></li><li><a href="#v:failures">failures</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></li></ul>}</li><li class="src short"><span class="keyword">type</span> <a href="#t:Path">Path</a> = [<a href="Test-HUnit-Base.html#t:Node">Node</a>]</li><li class="src short"><span class="keyword">data</span> <a href="#t:Node">Node</a> <ul class="subs"><li>= <a href="#v:ListItem">ListItem</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a> </li><li>| <a href="#v:Label">Label</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> </li></ul></li><li class="src short"><a href="#v:testCasePaths">testCasePaths</a> :: <a href="Test-HUnit-Base.html#t:Test">Test</a> -> [<a href="Test-HUnit-Base.html#t:Path">Path</a>]</li><li class="src short"><a href="#v:testCaseCount">testCaseCount</a> :: <a href="Test-HUnit-Base.html#t:Test">Test</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></li><li class="src short"><span class="keyword">type</span> <a href="#t:ReportStart">ReportStart</a> us = <a href="Test-HUnit-Base.html#t:State">State</a> -> us -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> us</li><li class="src short"><span class="keyword">type</span> <a href="#t:ReportProblem">ReportProblem</a> us = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -> <a href="Test-HUnit-Base.html#t:State">State</a> -> us -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> us</li><li class="src short"><a href="#v:performTest">performTest</a> :: <a href="Test-HUnit-Base.html#t:ReportStart">ReportStart</a> us -> <a href="Test-HUnit-Base.html#t:ReportProblem">ReportProblem</a> us -> <a href="Test-HUnit-Base.html#t:ReportProblem">ReportProblem</a> us -> us -> <a href="Test-HUnit-Base.html#t:Test">Test</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> (<a href="Test-HUnit-Base.html#t:Counts">Counts</a>, us)</li></ul></div><div id="interface"><h2 id="g:1">Declaring tests </h2><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Test" class="def">Test</a> <a href="src/Test-HUnit-Base.html#Test" class="link">Source</a></p><div class="doc"><p>The basic structure used to create an annotated tree of test cases. </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:TestCase" class="def">TestCase</a> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></td><td class="doc"><p>A single, independent test case composed. </p></td></tr><tr><td class="src"><a name="v:TestList" class="def">TestList</a> [<a href="Test-HUnit-Base.html#t:Test">Test</a>]</td><td class="doc"><p>A set of <code>Test</code>s sharing the same level in the hierarchy. </p></td></tr><tr><td class="src"><a name="v:TestLabel" class="def">TestLabel</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> <a href="Test-HUnit-Base.html#t:Test">Test</a></td><td class="doc"><p>A name or description for a subtree of the <code>Test</code>s. </p></td></tr></table></div><div class="subs instances"><p id="control.i:Test" class="caption collapser" onclick="toggleSection('i:Test')">Instances</p><div id="section.i:Test" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> <a href="Test-HUnit-Base.html#t:Test">Test</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Test-HUnit-Base.html#t:Testable">Testable</a> <a href="Test-HUnit-Base.html#t:Test">Test</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:-126--61--63-" class="def">(~=?)</a><a href="src/Test-HUnit-Base.html#~%3D%3F" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> a, <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src">=> a</td><td class="doc"><p>The expected value </p></td></tr><tr><td class="src">-> a</td><td class="doc"><p>The actual value </p></td></tr><tr><td class="src">-> <a href="Test-HUnit-Base.html#t:Test">Test</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Shorthand for a test case that asserts equality (with the expected value on the left-hand side, and the actual value on the right-hand side). </p></div></div><div class="top"><p class="src"><a name="v:-126--63--61-" class="def">(~?=)</a><a href="src/Test-HUnit-Base.html#~%3F%3D" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> a, <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src">=> a</td><td class="doc"><p>The actual value </p></td></tr><tr><td class="src">-> a</td><td class="doc"><p>The expected value </p></td></tr><tr><td class="src">-> <a href="Test-HUnit-Base.html#t:Test">Test</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Shorthand for a test case that asserts equality (with the actual value on the left-hand side, and the expected value on the right-hand side). </p></div></div><div class="top"><p class="src"><a name="v:-126-:" class="def">(~:)</a> :: <a href="Test-HUnit-Base.html#t:Testable">Testable</a> t => <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -> t -> <a href="Test-HUnit-Base.html#t:Test">Test</a><a href="src/Test-HUnit-Base.html#~%3A" class="link">Source</a></p><div class="doc"><p>Creates a test from the specified <code><a href="Test-HUnit-Base.html#t:Testable">Testable</a></code>, with the specified label attached to it. </p><p>Since <code><a href="Test-HUnit-Base.html#t:Test">Test</a></code> is <code>Testable</code>, this can be used as a shorthand way of attaching a <code><a href="Test-HUnit-Base.html#v:TestLabel">TestLabel</a></code> to one or more tests. </p></div></div><div class="top"><p class="src"><a name="v:-126--63-" class="def">(~?)</a><a href="src/Test-HUnit-Base.html#~%3F" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Test-HUnit-Base.html#t:AssertionPredicable">AssertionPredicable</a> t</td><td class="doc empty"> </td></tr><tr><td class="src">=> t</td><td class="doc"><p>A value of which the asserted condition is predicated </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></td><td class="doc"><p>A message that is displayed on test failure </p></td></tr><tr><td class="src">-> <a href="Test-HUnit-Base.html#t:Test">Test</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Creates a test case resulting from asserting the condition obtained from the specified <code><a href="Test-HUnit-Base.html#t:AssertionPredicable">AssertionPredicable</a></code>. </p></div></div><h2 id="g:2">Making assertions </h2><div class="top"><p class="src"><a name="v:assertFailure" class="def">assertFailure</a><a href="src/Test-HUnit-Lang.html#assertFailure" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></td><td class="doc"><p>A message that is displayed with the assertion failure </p></td></tr><tr><td class="src">-> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Unconditionally signals that a failure has occured. All other assertions can be expressed with the form: </p><pre> if conditionIsMet then IO () else assertFailure msg </pre></div></div><div class="top"><p class="src"><a name="v:assertBool" class="def">assertBool</a><a href="src/Test-HUnit-Base.html#assertBool" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></td><td class="doc"><p>The message that is displayed if the assertion fails </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Bool.html#t:Bool">Bool</a></td><td class="doc"><p>The condition </p></td></tr><tr><td class="src">-> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Asserts that the specified condition holds. </p></div></div><div class="top"><p class="src"><a name="v:assertEqual" class="def">assertEqual</a><a href="src/Test-HUnit-Base.html#assertEqual" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> a, <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src">=> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></td><td class="doc"><p>The message prefix </p></td></tr><tr><td class="src">-> a</td><td class="doc"><p>The expected value </p></td></tr><tr><td class="src">-> a</td><td class="doc"><p>The actual value </p></td></tr><tr><td class="src">-> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Asserts that the specified actual value is equal to the expected value. The output message will contain the prefix, the expected value, and the actual value. </p><p>If the prefix is the empty string (i.e., <code>""</code>), then the prefix is omitted and only the expected and actual values are output. </p></div></div><div class="top"><p class="src"><a name="v:assertString" class="def">assertString</a><a href="src/Test-HUnit-Base.html#assertString" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></td><td class="doc"><p>The message that is displayed with the assertion failure </p></td></tr><tr><td class="src">-> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Signals an assertion failure if a non-empty message (i.e., a message other than <code>""</code>) is passed. </p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:Assertion" class="def">Assertion</a> = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t:-40--41-">()</a><a href="src/Test-HUnit-Lang.html#Assertion" class="link">Source</a></p><div class="doc"><p>When an assertion is evaluated, it will output a message if and only if the assertion fails. </p><p>Test cases are composed of a sequence of one or more assertions. </p></div></div><div class="top"><p class="src"><a name="v:-64--61--63-" class="def">(@=?)</a><a href="src/Test-HUnit-Base.html#%40%3D%3F" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> a, <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src">=> a</td><td class="doc"><p>The expected value </p></td></tr><tr><td class="src">-> a</td><td class="doc"><p>The actual value </p></td></tr><tr><td class="src">-> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Asserts that the specified actual value is equal to the expected value (with the expected value on the left-hand side). </p></div></div><div class="top"><p class="src"><a name="v:-64--63--61-" class="def">(@?=)</a><a href="src/Test-HUnit-Base.html#%40%3F%3D" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> a, <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src">=> a</td><td class="doc"><p>The actual value </p></td></tr><tr><td class="src">-> a</td><td class="doc"><p>The expected value </p></td></tr><tr><td class="src">-> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Asserts that the specified actual value is equal to the expected value (with the actual value on the left-hand side). </p></div></div><div class="top"><p class="src"><a name="v:-64--63-" class="def">(@?)</a><a href="src/Test-HUnit-Base.html#%40%3F" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Test-HUnit-Base.html#t:AssertionPredicable">AssertionPredicable</a> t</td><td class="doc empty"> </td></tr><tr><td class="src">=> t</td><td class="doc"><p>A value of which the asserted condition is predicated </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></td><td class="doc"><p>A message that is displayed if the assertion fails </p></td></tr><tr><td class="src">-> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Asserts that the condition obtained from the specified <code><a href="Test-HUnit-Base.html#t:AssertionPredicable">AssertionPredicable</a></code> holds. </p></div></div><h2 id="g:3">Extending the assertion functionality </h2><div class="top"><p class="src"><span class="keyword">class</span> <a name="t:Assertable" class="def">Assertable</a> t <span class="keyword">where</span><a href="src/Test-HUnit-Base.html#Assertable" class="link">Source</a></p><div class="doc"><p>Allows the extension of the assertion mechanism. </p><p>Since an <code><a href="Test-HUnit-Base.html#t:Assertion">Assertion</a></code> can be a sequence of <code>Assertion</code>s and <code>IO</code> actions, there is a fair amount of flexibility of what can be achieved. As a rule, the resulting <code>Assertion</code> should be the body of a <code><a href="Test-HUnit-Base.html#v:TestCase">TestCase</a></code> or part of a <code>TestCase</code>; it should not be used to assert multiple, independent conditions. </p><p>If more complex arrangements of assertions are needed, <code><a href="Test-HUnit-Base.html#t:Test">Test</a></code>s and <code><a href="Test-HUnit-Base.html#t:Testable">Testable</a></code> should be used. </p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:assert" class="def">assert</a> :: t -> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a><a href="src/Test-HUnit-Base.html#assert" class="link">Source</a></p></div><div class="subs instances"><p id="control.i:Assertable" class="caption collapser" onclick="toggleSection('i:Assertable')">Instances</p><div id="section.i:Assertable" class="show"><table><tr><td class="src"><a href="Test-HUnit-Base.html#t:Assertable">Assertable</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Bool.html#t:Bool">Bool</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Test-HUnit-Base.html#t:Assertable">Assertable</a> ()</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Test-HUnit-Base.html#t:ListAssertable">ListAssertable</a> t => <a href="Test-HUnit-Base.html#t:Assertable">Assertable</a> [t]</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Test-HUnit-Base.html#t:Assertable">Assertable</a> t => <a href="Test-HUnit-Base.html#t:Assertable">Assertable</a> (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> t)</td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">class</span> <a name="t:ListAssertable" class="def">ListAssertable</a> t <span class="keyword">where</span><a href="src/Test-HUnit-Base.html#ListAssertable" class="link">Source</a></p><div class="doc"><p>A specialized form of <code><a href="Test-HUnit-Base.html#t:Assertable">Assertable</a></code> to handle lists. </p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:listAssert" class="def">listAssert</a> :: [t] -> <a href="Test-HUnit-Base.html#t:Assertion">Assertion</a><a href="src/Test-HUnit-Base.html#listAssert" class="link">Source</a></p></div><div class="subs instances"><p id="control.i:ListAssertable" class="caption collapser" onclick="toggleSection('i:ListAssertable')">Instances</p><div id="section.i:ListAssertable" class="show"><table><tr><td class="src"><a href="Test-HUnit-Base.html#t:ListAssertable">ListAssertable</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:Char">Char</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:AssertionPredicate" class="def">AssertionPredicate</a> = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Bool.html#t:Bool">Bool</a><a href="src/Test-HUnit-Base.html#AssertionPredicate" class="link">Source</a></p><div class="doc"><p>The result of an assertion that hasn't been evaluated yet. </p><p>Most test cases follow the following steps: </p><ol><li> Do some processing or an action. </li><li> Assert certain conditions. </li></ol><p>However, this flow is not always suitable. <code>AssertionPredicate</code> allows for additional steps to be inserted without the initial action to be affected by side effects. Additionally, clean-up can be done before the test case has a chance to end. A potential work flow is: </p><ol><li> Write data to a file. </li><li> Read data from a file, evaluate conditions. </li><li> Clean up the file. </li><li> Assert that the side effects of the read operation meet certain conditions. </li><li> Assert that the conditions evaluated in step 2 are met. </li></ol></div></div><div class="top"><p class="src"><span class="keyword">class</span> <a name="t:AssertionPredicable" class="def">AssertionPredicable</a> t <span class="keyword">where</span><a href="src/Test-HUnit-Base.html#AssertionPredicable" class="link">Source</a></p><div class="doc"><p>Used to signify that a data type can be converted to an assertion predicate. </p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:assertionPredicate" class="def">assertionPredicate</a> :: t -> <a href="Test-HUnit-Base.html#t:AssertionPredicate">AssertionPredicate</a><a href="src/Test-HUnit-Base.html#assertionPredicate" class="link">Source</a></p></div><div class="subs instances"><p id="control.i:AssertionPredicable" class="caption collapser" onclick="toggleSection('i:AssertionPredicable')">Instances</p><div id="section.i:AssertionPredicable" class="show"><table><tr><td class="src"><a href="Test-HUnit-Base.html#t:AssertionPredicable">AssertionPredicable</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Bool.html#t:Bool">Bool</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Test-HUnit-Base.html#t:AssertionPredicable">AssertionPredicable</a> t => <a href="Test-HUnit-Base.html#t:AssertionPredicable">AssertionPredicable</a> (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> t)</td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">class</span> <a name="t:Testable" class="def">Testable</a> t <span class="keyword">where</span><a href="src/Test-HUnit-Base.html#Testable" class="link">Source</a></p><div class="doc"><p>Provides a way to convert data into a <code>Test</code> or set of <code>Test</code>. </p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:test" class="def">test</a> :: t -> <a href="Test-HUnit-Base.html#t:Test">Test</a><a href="src/Test-HUnit-Base.html#test" class="link">Source</a></p></div><div class="subs instances"><p id="control.i:Testable" class="caption collapser" onclick="toggleSection('i:Testable')">Instances</p><div id="section.i:Testable" class="show"><table><tr><td class="src"><a href="Test-HUnit-Base.html#t:Testable">Testable</a> <a href="Test-HUnit-Base.html#t:Test">Test</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Test-HUnit-Base.html#t:Testable">Testable</a> t => <a href="Test-HUnit-Base.html#t:Testable">Testable</a> [t]</td><td class="doc empty"> </td></tr><tr><td class="src"><a href="Test-HUnit-Base.html#t:Assertable">Assertable</a> t => <a href="Test-HUnit-Base.html#t:Testable">Testable</a> (<a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> t)</td><td class="doc empty"> </td></tr></table></div></div></div><h2 id="g:4">Test execution </h2><div class="doc"><p>Note: the rest of the functionality in this module is intended for implementors of test controllers. If you just want to run your tests cases, simply use a test controller, such as the text-based controller in <a href="Test-HUnit-Text.html">Test.HUnit.Text</a>. </p></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:State" class="def">State</a> <a href="src/Test-HUnit-Base.html#State" class="link">Source</a></p><div class="doc"><p>Keeps track of the remaining tests and the results of the performed tests. As each test is performed, the path is removed and the counts are updated as appropriate. </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:State" class="def">State</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:path" class="def">path</a> :: <a href="Test-HUnit-Base.html#t:Path">Path</a></dt><dd class="doc empty"> </dd><dt class="src"><a name="v:counts" class="def">counts</a> :: <a href="Test-HUnit-Base.html#t:Counts">Counts</a></dt><dd class="doc empty"> </dd></dl><div class="clear"></div></div></td></tr></table></div><div class="subs instances"><p id="control.i:State" class="caption collapser" onclick="toggleSection('i:State')">Instances</p><div id="section.i:State" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> <a href="Test-HUnit-Base.html#t:State">State</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Read.html#t:Read">Read</a> <a href="Test-HUnit-Base.html#t:State">State</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> <a href="Test-HUnit-Base.html#t:State">State</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Counts" class="def">Counts</a> <a href="src/Test-HUnit-Base.html#Counts" class="link">Source</a></p><div class="doc"><p>A data structure that hold the results of tests that have been performed up until this point. </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:Counts" class="def">Counts</a></td><td class="doc empty"> </td></tr><tr><td colspan="2"><div class="subs fields"><p class="caption">Fields</p><dl><dt class="src"><a name="v:cases" class="def">cases</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></dt><dd class="doc empty"> </dd><dt class="src"><a name="v:tried" class="def">tried</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></dt><dd class="doc empty"> </dd><dt class="src"><a name="v:errors" class="def">errors</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></dt><dd class="doc empty"> </dd><dt class="src"><a name="v:failures" class="def">failures</a> :: <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></dt><dd class="doc empty"> </dd></dl><div class="clear"></div></div></td></tr></table></div><div class="subs instances"><p id="control.i:Counts" class="caption collapser" onclick="toggleSection('i:Counts')">Instances</p><div id="section.i:Counts" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> <a href="Test-HUnit-Base.html#t:Counts">Counts</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Read.html#t:Read">Read</a> <a href="Test-HUnit-Base.html#t:Counts">Counts</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> <a href="Test-HUnit-Base.html#t:Counts">Counts</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:Path" class="def">Path</a> = [<a href="Test-HUnit-Base.html#t:Node">Node</a>]<a href="src/Test-HUnit-Base.html#Path" class="link">Source</a></p><div class="doc"><p>Uniquely describes the location of a test within a test hierarchy. Node order is from test case to root. </p></div></div><div class="top"><p class="src"><span class="keyword">data</span> <a name="t:Node" class="def">Node</a> <a href="src/Test-HUnit-Base.html#Node" class="link">Source</a></p><div class="doc"><p>Composed into <code><a href="Test-HUnit-Base.html#t:Path">Path</a></code>s. </p></div><div class="subs constructors"><p class="caption">Constructors</p><table><tr><td class="src"><a name="v:ListItem" class="def">ListItem</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a name="v:Label" class="def">Label</a> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a></td><td class="doc empty"> </td></tr></table></div><div class="subs instances"><p id="control.i:Node" class="caption collapser" onclick="toggleSection('i:Node')">Instances</p><div id="section.i:Node" class="show"><table><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Eq.html#t:Eq">Eq</a> <a href="Test-HUnit-Base.html#t:Node">Node</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Read.html#t:Read">Read</a> <a href="Test-HUnit-Base.html#t:Node">Node</a></td><td class="doc empty"> </td></tr><tr><td class="src"><a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Text-Show.html#t:Show">Show</a> <a href="Test-HUnit-Base.html#t:Node">Node</a></td><td class="doc empty"> </td></tr></table></div></div></div><div class="top"><p class="src"><a name="v:testCasePaths" class="def">testCasePaths</a> :: <a href="Test-HUnit-Base.html#t:Test">Test</a> -> [<a href="Test-HUnit-Base.html#t:Path">Path</a>]<a href="src/Test-HUnit-Base.html#testCasePaths" class="link">Source</a></p><div class="doc"><p>Determines the paths for all <code><a href="Test-HUnit-Base.html#v:TestCase">TestCase</a></code>s in a tree of <code>Test</code>s. </p></div></div><div class="top"><p class="src"><a name="v:testCaseCount" class="def">testCaseCount</a> :: <a href="Test-HUnit-Base.html#t:Test">Test</a> -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Int.html#t:Int">Int</a><a href="src/Test-HUnit-Base.html#testCaseCount" class="link">Source</a></p><div class="doc"><p>Counts the number of <code><a href="Test-HUnit-Base.html#v:TestCase">TestCase</a></code>s in a tree of <code>Test</code>s. </p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:ReportStart" class="def">ReportStart</a> us = <a href="Test-HUnit-Base.html#t:State">State</a> -> us -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> us<a href="src/Test-HUnit-Base.html#ReportStart" class="link">Source</a></p><div class="doc"><p>Report generator for reporting the start of a test run. </p></div></div><div class="top"><p class="src"><span class="keyword">type</span> <a name="t:ReportProblem" class="def">ReportProblem</a> us = <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/Data-Char.html#t:String">String</a> -> <a href="Test-HUnit-Base.html#t:State">State</a> -> us -> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> us<a href="src/Test-HUnit-Base.html#ReportProblem" class="link">Source</a></p><div class="doc"><p>Report generator for reporting problems that have occurred during a test run. Problems may be errors or assertion failures. </p></div></div><div class="top"><p class="src"><a name="v:performTest" class="def">performTest</a><a href="src/Test-HUnit-Base.html#performTest" class="link">Source</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Test-HUnit-Base.html#t:ReportStart">ReportStart</a> us</td><td class="doc"><p>report generator for the test run start </p></td></tr><tr><td class="src">-> <a href="Test-HUnit-Base.html#t:ReportProblem">ReportProblem</a> us</td><td class="doc"><p>report generator for errors during the test run </p></td></tr><tr><td class="src">-> <a href="Test-HUnit-Base.html#t:ReportProblem">ReportProblem</a> us</td><td class="doc"><p>report generator for assertion failures during the test run </p></td></tr><tr><td class="src">-> us</td><td class="doc empty"> </td></tr><tr><td class="src">-> <a href="Test-HUnit-Base.html#t:Test">Test</a></td><td class="doc"><p>the test to be executed </p></td></tr><tr><td class="src">-> <a href="/usr/share/doc/ghc/html/libraries/base-4.3.1.0/System-IO.html#t:IO">IO</a> (<a href="Test-HUnit-Base.html#t:Counts">Counts</a>, us)</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Performs a test run with the specified report generators. </p><p>This handles the actual running of the tests. Most developers will want to use <code>HUnit.Text.runTestTT</code> instead. A developer could use this function to execute tests via another IO system, such as a GUI, or to output the results in a different manner (e.g., upload XML-formatted results to a webservice). </p><p>Note that the counts in a start report do not include the test case being started, whereas the counts in a problem report do include the test case just finished. The principle is that the counts are sampled only between test case executions. As a result, the number of test case successes always equals the difference of test cases tried and the sum of test case errors and failures. </p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.9.2</p></div></body></html>