blob: 351a51742dfbc26d6acadd93c27cd5d377897a35 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
import Test.QuickCheck
import Test.Hspec
import Blessings
instance Arbitrary a => Arbitrary (Blessings a) where
arbitrary =
oneof
[ Plain <$> arbitrary
, pure Empty
, (<>) <$> arbitrary <*> arbitrary
, SGR <$> arbitrary <*> arbitrary
]
main :: IO ()
main =
hspec $ do
describe "Blessings" $ do
it "obeys the Semigroup laws" $
property $ \(x :: Blessings String) y z ->
(x <> y) <> z == x <> (y <> z)
it "obeys the Monoid laws" $
property $ \(x :: Blessings String) ->
x <> mempty == x && x == mempty <> x
|