summaryrefslogtreecommitdiffstats
path: root/test/Spec.hs
blob: 298eb0432ddd600c609f692deeb847faf4964660 (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
{-# LANGUAGE ScopedTypeVariables #-}
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