diff options
author | David Waern <david.waern@gmail.com> | 2009-11-28 19:32:40 +0000 |
---|---|---|
committer | David Waern <david.waern@gmail.com> | 2009-11-28 19:32:40 +0000 |
commit | a5138aa6b3da207b78f2624f0fb41b0de6e8f02a (patch) | |
tree | 312f6d93147d044ba51b5c568bfa24994d49c8d5 | |
parent | c594ca6638ed868a0a2ff11e6e0a469e44a08ff2 (diff) |
Add an Arbitrary instance for HsDoc
-rw-r--r-- | src/Haddock/Types.hs | 25 |
1 files changed, 25 insertions, 0 deletions
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) |