From fa87fc922cd4c34b46baa32be762dda495ef6a2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Tue, 29 Jan 2019 23:03:22 +0100 Subject: Blessings: add test ~ change SGR type to Word8 + add hspec with QuickCheck --- test/Spec.hs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/Spec.hs (limited to 'test') diff --git a/test/Spec.hs b/test/Spec.hs new file mode 100644 index 0000000..298eb04 --- /dev/null +++ b/test/Spec.hs @@ -0,0 +1,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 -- cgit v1.2.3