summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorKierán Meinhardt <kieran.meinhardt@gmail.com>2019-01-29 23:03:22 +0100
committerKierán Meinhardt <kieran.meinhardt@gmail.com>2019-02-05 20:52:24 +0100
commitfa87fc922cd4c34b46baa32be762dda495ef6a2b (patch)
treebcd0600a8ba714278a74d210232f2363475d2d06 /test
parente75d0cf94582a5aa6dde781b8428ffff45cf7e76 (diff)
Blessings: add test
~ change SGR type to Word8 + add hspec with QuickCheck
Diffstat (limited to 'test')
-rw-r--r--test/Spec.hs25
1 files changed, 25 insertions, 0 deletions
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