Expand Haddock to run over test files as well
[ganeti-local] / test / hs / Test / Ganeti / BasicTypes.hs
index a74bc29..d365ab0 100644 (file)
@@ -7,7 +7,7 @@
 
 {-
 
-Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
+Copyright (C) 2009, 2010, 2011, 2012, 2013 Google Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -56,24 +56,31 @@ instance (Arbitrary a) => Arbitrary (Result a) where
 
 -- * Test cases
 
--- | Tests the functor identity law (fmap id == id).
+-- | Tests the functor identity law:
+--
+-- > fmap id == id
 prop_functor_id :: Result Int -> Property
 prop_functor_id ri =
   fmap id ri ==? ri
 
--- | Tests the functor composition law (fmap (f . g)  ==  fmap f . fmap g).
+-- | Tests the functor composition law:
+--
+-- > fmap (f . g)  ==  fmap f . fmap g
 prop_functor_composition :: Result Int
                          -> Fun Int Int -> Fun Int Int -> Property
 prop_functor_composition ri (Fun _ f) (Fun _ g) =
   fmap (f . g) ri ==? (fmap f . fmap g) ri
 
--- | Tests the applicative identity law (pure id <*> v = v).
+-- | Tests the applicative identity law:
+--
+-- > pure id <*> v = v
 prop_applicative_identity :: Result Int -> Property
 prop_applicative_identity v =
   pure id <*> v ==? v
 
--- | Tests the applicative composition law (pure (.) <*> u <*> v <*> w
--- = u <*> (v <*> w)).
+-- | Tests the applicative composition law:
+--
+-- > pure (.) <*> u <*> v <*> w = u <*> (v <*> w)
 prop_applicative_composition :: Result (Fun Int Int)
                              -> Result (Fun Int Int)
                              -> Result Int
@@ -83,33 +90,47 @@ prop_applicative_composition u v w =
       v' = fmap apply v
   in pure (.) <*> u' <*> v' <*> w ==? u' <*> (v' <*> w)
 
--- | Tests the applicative homomorphism law (pure f <*> pure x = pure (f x)).
+-- | Tests the applicative homomorphism law:
+--
+-- > pure f <*> pure x = pure (f x)
 prop_applicative_homomorphism :: Fun Int Int -> Int -> Property
 prop_applicative_homomorphism (Fun _ f) x =
   ((pure f <*> pure x)::Result Int) ==? pure (f x)
 
--- | Tests the applicative interchange law (u <*> pure y = pure ($ y) <*> u).
+-- | Tests the applicative interchange law:
+--
+-- > u <*> pure y = pure ($ y) <*> u
 prop_applicative_interchange :: Result (Fun Int Int)
                              -> Int -> Property
 prop_applicative_interchange f y =
   let u = fmap apply f -- need to extract the actual function from Fun
   in u <*> pure y ==? pure ($ y) <*> u
 
--- | Tests the applicative\/functor correspondence (fmap f x = pure f <*> x).
+-- | Tests the applicative\/functor correspondence:
+--
+-- > fmap f x = pure f <*> x
 prop_applicative_functor :: Fun Int Int -> Result Int -> Property
 prop_applicative_functor (Fun _ f) x =
   fmap f x ==? pure f <*> x
 
--- | Tests the applicative\/monad correspondence (pure = return and
--- (<*>) = ap).
+-- | Tests the applicative\/monad correspondence:
+--
+-- > pure = return
+--
+-- > (<*>) = ap
 prop_applicative_monad :: Int -> Result (Fun Int Int) -> Property
 prop_applicative_monad v f =
   let v' = pure v :: Result Int
       f' = fmap apply f -- need to extract the actual function from Fun
   in v' ==? return v .&&. (f' <*> v') ==? f' `ap` v'
 
--- | Tests the monad laws (return a >>= k == k a, m >>= return == m, m
--- >>= (\x -> k x >>= h) == (m >>= k) >>= h).
+-- | Tests the monad laws:
+--
+-- > return a >>= k == k a
+--
+-- > m >>= return == m
+--
+-- > m >>= (\x -> k x >>= h) == (m >>= k) >>= h
 prop_monad_laws :: Int -> Result Int
                 -> Fun Int (Result Int)
                 -> Fun Int (Result Int)
@@ -122,7 +143,11 @@ prop_monad_laws a m (Fun _ k) (Fun _ h) =
     ((m >>= (\x -> k x >>= h)) ==? ((m >>= k) >>= h))
   ]
 
--- | Tests the monad plus laws ( mzero >>= f = mzero, v >> mzero = mzero).
+-- | Tests the monad plus laws:
+--
+-- > mzero >>= f = mzero
+--
+-- > v >> mzero = mzero
 prop_monadplus_mzero :: Result Int -> Fun Int (Result Int) -> Property
 prop_monadplus_mzero v (Fun _ f) =
   printTestCase "mzero >>= f = mzero" ((mzero >>= f) ==? mzero) .&&.