AC-MiniTest-1.1.1: A simple test framework.

Safe HaskellSafe-Infered

Test.AC.Class.Functor

Contents

Description

Properties for testing that instances of the Functor class perform correctly.

This testing requires an Eq instance, which not all Functors actually have. It also requires a Show instance, which is also uncommon. The Label1 wrapper may be useful in dealing with the Show requirement.

Tests are supplied both in regular "unlabelled" form, and also in a special "labelled" form, where function objects have Labels attached to them. Because of this, the function used for each test can be recorded in the test log, which can be quite helpful.

Synopsis

Unlabelled tests

p_map_id :: (Functor f, Eq (f x), Show (f x)) => f x -> TestSource

Check that fmap id == id.

p_map_compose :: (Functor f, Eq (f z), Show (f x), Show (f y), Show (f z)) => f x -> (x -> y) -> (y -> z) -> TestSource

Check that fmap (f . g) == fmap f . fmap g.

p_Functor :: (Functor f, Eq (f x), Show (f x)) => [f x] -> [x -> x] -> TestSource

Given a list of distinct Functor values and functions, perform all tests on all combinations of inputs. (If the inputs are not distinct, some redundant tests will be performed.)

The argument types are somewhat constrained to keep the type signature reasonably simple.

Labelled tests

p_map_compose_L :: (Functor f, Eq (f z), Show (f x), Show (f y), Show (f z)) => f x -> Label (x -> y) -> Label (y -> z) -> TestSource

Check that fmap (f . g) == fmap f . fmap g.

p_Functor_L :: (Functor f, Eq (f x), Show (f x)) => [f x] -> [Label (x -> x)] -> TestSource

Given a list of distinct Functor values and functions, perform all tests on all combinations of inputs. (If the inputs are not distinct, some redundant tests will be performed.)

The argument types are somewhat constrained to keep the function's type signature reasonably simple.