prednote-0.16.0.0: Build and evaluate trees of predicates

Safe HaskellNone

Data.Prednote.Test

Contents

Description

Helps you build tests that run against a series of items.

Synopsis

Test data types

type Name = TextSource

The name of a test or of a group.

data Verbosity Source

How verbose to be when showing the results of running a Pdct on a single subject.

Constructors

HideAll

Do not show any results from the Pdct

ShowDefaults

Show results according to the default settings provided in the Result itself

ShowAll

Show all Result

type TrueVerbosity = VerbositySource

Use this verbosity for subjects that are True

type FalseVerbosity = VerbositySource

Use this verbosity for subjects that are False

data ShowTest Source

Determines whether to show any of the results from a single test.

Constructors

HideTest

Do not show any results from this test

ShowFirstLine TrueVerbosity FalseVerbosity

Show the first line, which indicates whether the test passed or failed and gives the label for the test. Whether to show individual subjects is determined by the TrueVerbosity and FalseVerbosity.

Instances

data TestVerbosity Source

Determines which ShowTest to use for a particular test.

Constructors

TestVerbosity 

Fields

onPass :: ShowTest

Use this ShowTest when the test passes

onFail :: ShowTest

Use this ShowTest when the test fails

data Test a Source

A single test.

Constructors

Test 

Fields

testName :: Name
 
testPass :: [Result] -> Pass

Applied to the results of all applications of testFunc; determines whether the test passes or fails.

testFunc :: a -> Result

This function is applied to each subject.

testVerbosity :: TestVerbosity

Default verbosity for the test.

Pre-built tests

eachSubjectMustBeTrue :: Pdct a -> Name -> Test aSource

The test passes if each subject returns True.

nSubjectsMustBeTrueSource

Arguments

:: Pdct a 
-> Name 
-> Int

The number of subjects that must be True. This should be a positive number.

-> Test a 

The test passes if at least a given number of subjects are True.

Running and showing tests

evalTest :: Test a -> [a] -> TestResult aSource

Evaluates a test for a given list of subjects.

showResultSource

Arguments

:: IndentAmt

Indent each level by this many spaces

-> (a -> Text)

Shows each subject. The function should return a single-line text without a trailing newline.

-> Maybe TestVerbosity

If Just, use this TestVerbosity when showing the test. If Nothing, use the default verbosity.

-> TestResult a

The result to show

-> [Chunk] 

Shows a result with indenting.