{- |
    Module      :  Test.SDP.Eq
    Copyright   :  (c) Andrey Mulik 2019
    License     :  BSD-style
    Maintainer  :  work.a.mulik@gmail.com
    Portability :  portable
    
    @Test.SDP.Eq@ provides basic test suite for 'Eq' instances.
-}
module Test.SDP.Eq
(
  -- * Eq test
  TestEq, eqTest
)
where

default ()

--------------------------------------------------------------------------------

-- | TestEq is service type synonym for more comfortable quickCheck using.
type TestEq l = l -> l -> l -> Bool

--------------------------------------------------------------------------------

-- | eqTest is basic test suite for 'Eq' instances.
eqTest :: (Eq l) => l -> l -> l -> Bool
eqTest :: l -> l -> l -> Bool
eqTest l
xs l
ys l
zs = [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and
  [
    -- transitive
    (l
xs l -> l -> Bool
forall a. Eq a => a -> a -> Bool
== l
ys Bool -> Bool -> Bool
&& l
ys l -> l -> Bool
forall a. Eq a => a -> a -> Bool
== l
zs) Bool -> Bool -> Bool
forall a. Ord a => a -> a -> Bool
<= (l
xs l -> l -> Bool
forall a. Eq a => a -> a -> Bool
== l
zs),
    
    -- symmetric
    (l
xs l -> l -> Bool
forall a. Eq a => a -> a -> Bool
== l
ys) Bool -> Bool -> Bool
forall a. Eq a => a -> a -> Bool
== (l
ys l -> l -> Bool
forall a. Eq a => a -> a -> Bool
== l
xs),
    
    -- reflexive
    l
xs l -> l -> Bool
forall a. Eq a => a -> a -> Bool
== l
xs
  ]