module Test.AC.Class.Eq where
import Test.AC.Test
p_reflexive :: (Show x, Eq x) => x -> Test
p_reflexive x =
title "x == x" $
x ?= x
p_symmetric :: (Show x, Eq x) => x -> x -> Test
p_symmetric x y =
title "if x == y then y == x" $
argument "x" x $
argument "y" y $
temporary "x == y" (x == y) $
(y == x) ?= (x == y)
p_transitive :: (Show x, Eq x) => x -> x -> x -> Test
p_transitive x y z =
title "if x == y and y == z then x == z" $
argument "x" x $
argument "y" y $
argument "z" z $
temporary "x == y" (x == y) $
temporary "y == z" (y == z) $
if (x /= y) && (y /= z)
then inapplicable
else (x == z) ?= ((x == y) && (y == z))
p_not_equal :: (Show x, Eq x) => x -> x -> Test
p_not_equal x y =
title "x /= y is not(x == y)" $
argument "x" x $
argument "y" y $
temporary "x == y" (x == y) $
(x /= y) ?= not (x == y)
p_Eq :: (Show x, Eq x) => [x] -> Test
p_Eq xs =
title "p_Eq" $
argument "xs" xs $
tests
[
title "p_reflexive" $ tests [ p_reflexive x | x <- xs ],
title "p_symmetric" $ tests [ p_symmetric x y | x <- xs, y <- xs ],
title "p_transitive" $ tests [ p_transitive x y z | x <- xs, y <- xs, z <- xs ],
title "p_not_equal" $ tests [ p_not_equal x y | x <- xs, y <- xs ]
]