-- | test property equality for the given Collection
--
-- This does to enforce
testEqualityProperties :: forall collection
                        . ( IsList collection
                          , Element collection ~ Item collection
                          , Typeable collection
                          , Eq collection,   Eq (Element collection)
                          , Show collection, Show (Element collection)
                          , Ord collection,  Ord (Element collection)
                          )
                       => Proxy collection
                       -> Gen (Element collection)
                       -> Test
testEqualityProperties proxy genElement = Group "equality"
    [ Property "x == x" $ withElements $ \l -> let col = fromListP proxy l in col === col
    , Property "x == y" $ with2Elements $ \(l1, l2) ->
        (fromListP proxy l1 == fromListP proxy l2) === (l1 == l2)
    ]
  where
    withElements f = forAll (generateListOfElement genElement) f
    with2Elements f = forAll ((,) <$> generateListOfElement genElement <*> generateListOfElement genElement) f
testEqualityProperties :: forall collection
                        . ( IsList collection
                          , Element collection ~ Item collection
                          , Typeable collection
                          , Eq collection,   Eq (Element collection)
                          , Show collection, Show (Element collection)
                          , Ord collection,  Ord (Element collection)
                          )
                       => Proxy collection
                       -> Gen (Element collection)
                       -> Test
testEqualityProperties proxy genElement = Group "equality"
    [ Property "x == x" $ withElements $ \l -> let col = fromListP proxy l in col === col
    , Property "x == y" $ with2Elements $ \(l1, l2) ->
        (fromListP proxy l1 == fromListP proxy l2) === (l1 == l2)
    ]
  where
    withElements f = forAll (generateListOfElement genElement) f
    with2Elements f = forAll ((,) <$> generateListOfElement genElement <*> generateListOfElement genElement) f
testEqualityProperties proxy genElement = Group "equality"
    [ Property "x == x" $ withElements $ \l -> let col = fromListP proxy l in col === col
    , Property "x == y" $ with2Elements $ \(l1, l2) ->
        (fromListP proxy l1 == fromListP proxy l2) === (l1 == l2)
    ]
  where
    withElements f = forAll (generateListOfElement genElement) f
    with2Elements f = forAll ((,) <$> generateListOfElement genElement <*> generateListOfElement genElement) f