From a5138aa6b3da207b78f2624f0fb41b0de6e8f02a Mon Sep 17 00:00:00 2001 From: David Waern Date: Sat, 28 Nov 2009 19:32:40 +0000 Subject: Add an Arbitrary instance for HsDoc --- src/Haddock/Types.hs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Haddock/Types.hs b/src/Haddock/Types.hs index 0a8f0407..86e4cea2 100644 --- a/src/Haddock/Types.hs +++ b/src/Haddock/Types.hs @@ -29,6 +29,9 @@ import qualified Data.Map as Map import GHC hiding (NoLink) import Name +#ifdef TEST +import Test.QuickCheck +#endif -- convenient short-hands type Decl = LHsDecl Name @@ -289,6 +292,28 @@ data HsDoc id deriving (Eq, Show, Functor) +#ifdef TEST +-- TODO: use derive +instance Arbitrary a => Arbitrary (HsDoc a) where + arbitrary = + oneof [ return DocEmpty + , do { a <- arbitrary; b <- arbitrary; return (DocAppend a b) } + , fmap DocString arbitrary + , fmap DocParagraph arbitrary + , fmap DocIdentifier arbitrary + , fmap DocModule arbitrary + , fmap DocEmphasis arbitrary + , fmap DocMonospaced arbitrary + , fmap DocUnorderedList arbitrary + , fmap DocOrderedList arbitrary + , fmap DocDefList arbitrary + , fmap DocCodeBlock arbitrary + , fmap DocURL arbitrary + , fmap DocPic arbitrary + , fmap DocAName arbitrary ] +#endif + + type LHsDoc id = Located (HsDoc id) -- cgit v1.2.3