2019-09-25 23:59:27 +03:00
|
|
|
module Data.Semigroup.App.Spec (testTree) where
|
2018-10-31 22:47:30 +03:00
|
|
|
|
2019-09-25 23:59:27 +03:00
|
|
|
import Data.Semigroup.App
|
|
|
|
import Hedgehog
|
|
|
|
import qualified Hedgehog.Gen as Gen
|
|
|
|
import qualified Hedgehog.Range as Range
|
|
|
|
import Properties
|
|
|
|
import qualified Test.Tasty as Tasty
|
|
|
|
import qualified Test.Tasty.Hedgehog as Tasty
|
2018-10-31 22:47:30 +03:00
|
|
|
|
2019-09-25 23:59:27 +03:00
|
|
|
app :: MonadGen m => m (App Maybe Integer)
|
|
|
|
app = App <$> Gen.maybe (Gen.integral (Range.linear 0 10000))
|
2018-10-31 22:47:30 +03:00
|
|
|
|
2019-09-25 23:59:27 +03:00
|
|
|
merge :: MonadGen m => m (AppMerge Maybe String)
|
|
|
|
merge = AppMerge <$> Gen.maybe (Gen.string (Range.linear 0 10) Gen.ascii)
|
2018-10-31 22:47:30 +03:00
|
|
|
|
2019-09-25 23:59:27 +03:00
|
|
|
testTree :: Tasty.TestTree
|
|
|
|
testTree = Tasty.testGroup "Data.Semigroup.App"
|
|
|
|
[ Tasty.testGroup "App"
|
|
|
|
[ Tasty.testProperty "is associative" (associative (<>) app)
|
|
|
|
]
|
|
|
|
, Tasty.testGroup "AppMerge"
|
|
|
|
[ Tasty.testProperty "is associative" (associative (<>) merge)
|
|
|
|
, Tasty.testProperty "is monoidal" (monoidal merge)
|
|
|
|
]
|
|
|
|
]
|