2019-08-31 19:17:27 +02:00
|
|
|
{-# LANGUAGE ApplicativeDo #-}
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
module Xanthous.Data.EntityMapSpec where
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Test.Prelude
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Xanthous.Data.EntityMap
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = defaultMain test
|
|
|
|
|
|
|
|
test :: TestTree
|
2019-09-15 19:00:28 +02:00
|
|
|
test = localOption (QuickCheckTests 20)
|
|
|
|
$ testGroup "Xanthous.Data.EntityMap"
|
2019-08-31 19:17:27 +02:00
|
|
|
[ testBatch $ monoid @(EntityMap Int) mempty
|
2019-09-15 19:00:28 +02:00
|
|
|
, testGroup "Deduplicate"
|
2019-09-20 18:03:30 +02:00
|
|
|
[ testGroup "Semigroup laws"
|
|
|
|
[ testProperty "associative" $ \(a :: Deduplicate (EntityMap Int)) b c ->
|
|
|
|
a <> (b <> c) === (a <> b) <> c
|
|
|
|
]
|
2019-09-15 19:00:28 +02:00
|
|
|
]
|
2019-08-31 19:17:27 +02:00
|
|
|
, testGroup "Eq laws"
|
|
|
|
[ testProperty "reflexivity" $ \(em :: EntityMap Int) ->
|
|
|
|
em == em
|
|
|
|
, testProperty "symmetric" $ \(em₁ :: EntityMap Int) em₂ ->
|
|
|
|
(em₁ == em₂) == (em₂ == em₁)
|
|
|
|
, testProperty "transitive" $ \(em₁ :: EntityMap Int) em₂ em₃ ->
|
|
|
|
if (em₁ == em₂ && em₂ == em₃)
|
|
|
|
then (em₁ == em₃)
|
|
|
|
else True
|
|
|
|
]
|
|
|
|
]
|