summaryrefslogtreecommitdiff
path: root/testsuite/tests/haddock
diff options
context:
space:
mode:
authorDavid Terei <davidterei@gmail.com>2011-07-20 11:09:03 -0700
committerDavid Terei <davidterei@gmail.com>2011-07-20 11:26:35 -0700
commit16514f272fb42af6e9c7674a9bd6c9dce369231f (patch)
treee4f332b45fe65e2a7a2451be5674f887b42bf199 /testsuite/tests/haddock
parentebd422aed41048476aa61dd4c520d43becd78682 (diff)
downloadhaskell-16514f272fb42af6e9c7674a9bd6c9dce369231f.tar.gz
Move tests from tests/ghc-regress/* to just tests/*
Diffstat (limited to 'testsuite/tests/haddock')
-rw-r--r--testsuite/tests/haddock/Makefile3
-rw-r--r--testsuite/tests/haddock/haddock_examples/Hidden.hs4
-rw-r--r--testsuite/tests/haddock/haddock_examples/Makefile3
-rw-r--r--testsuite/tests/haddock/haddock_examples/Test.hs407
-rw-r--r--testsuite/tests/haddock/haddock_examples/Visible.hs3
-rw-r--r--testsuite/tests/haddock/haddock_examples/haddock.Test.stderr159
-rw-r--r--testsuite/tests/haddock/haddock_examples/header.h5
-rw-r--r--testsuite/tests/haddock/haddock_examples/test.T6
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/Makefile3
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/all.T33
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA001.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA001.stderr7
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA002.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA002.stderr7
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA003.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA003.stderr7
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA004.hs8
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA004.stderr7
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA005.hs4
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA005.stderr7
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA006.hs6
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA006.stderr6
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA007.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA007.stderr7
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA008.hs7
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA008.stderr7
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA009.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA009.stderr7
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA010.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA010.stderr7
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA011.hs8
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA011.stderr7
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA012.hs11
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA012.stderr11
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA013.hs13
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA013.stderr13
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA014.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA014.stderr8
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA015.hs14
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA015.stderr14
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA016.hs4
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA016.stderr6
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA017.hs2
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA017.stderr5
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA018.hs4
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA018.stderr6
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA019.hs7
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA019.stderr7
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA020.hs15
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA020.stderr8
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA021.hs25
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA021.stderr11
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA022.hs11
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA022.stderr9
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA023.hs6
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA023.stderr10
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA024.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA024.stderr7
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA025.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA025.stderr7
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA026.hs6
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA026.stderr10
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA027.hs7
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA027.stderr11
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA028.hs6
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA028.stderr8
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA029.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA029.stderr6
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA030.hs10
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA030.stderr6
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA031.hs6
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA031.stderr9
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA032.hs8
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA032.stderr10
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA033.hs11
-rw-r--r--testsuite/tests/haddock/should_compile_flag_haddock/haddockA033.stderr11
-rw-r--r--testsuite/tests/haddock/should_compile_flag_nohaddock/Makefile3
-rw-r--r--testsuite/tests/haddock/should_compile_flag_nohaddock/all.T4
-rw-r--r--testsuite/tests/haddock/should_compile_flag_nohaddock/haddockB001.hs3
-rw-r--r--testsuite/tests/haddock/should_compile_flag_nohaddock/haddockB002.hs3
-rw-r--r--testsuite/tests/haddock/should_compile_flag_nohaddock/haddockB003.hs2
-rw-r--r--testsuite/tests/haddock/should_compile_flag_nohaddock/haddockB004.hs17
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/Makefile3
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/all.T33
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC001.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC002.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC003.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC004.hs8
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC005.hs4
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC006.hs6
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC007.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC008.hs7
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC009.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC010.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC011.hs8
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC012.hs11
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC013.hs14
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC014.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC015.hs14
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC016.hs4
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC017.hs2
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC018.hs4
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC019.hs7
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC020.hs15
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC021.hs25
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC022.hs11
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC023.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC024.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC025.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC026.hs6
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC027.hs21
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC028.hs6
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC029.hs5
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC030.hs10
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC031.hs6
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockC032.hs8
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockSimplUtilsBug.hs44
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_haddock/haddockSimplUtilsBug.stderr0
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_nohaddock/Makefile3
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_nohaddock/all.T4
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_nohaddock/haddockD001.hs3
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_nohaddock/haddockD002.hs3
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_nohaddock/haddockD003.hs2
-rw-r--r--testsuite/tests/haddock/should_compile_noflag_nohaddock/haddockD004.hs17
-rw-r--r--testsuite/tests/haddock/should_fail_flag_haddock/Makefile3
-rw-r--r--testsuite/tests/haddock/should_fail_flag_haddock/all.T4
-rw-r--r--testsuite/tests/haddock/should_fail_flag_haddock/haddockE001.hs2
-rw-r--r--testsuite/tests/haddock/should_fail_flag_haddock/haddockE001.stderr2
-rw-r--r--testsuite/tests/haddock/should_fail_flag_haddock/haddockE002.hs6
-rw-r--r--testsuite/tests/haddock/should_fail_flag_haddock/haddockE002.stderr2
-rw-r--r--testsuite/tests/haddock/should_fail_flag_haddock/haddockE003.hs9
-rw-r--r--testsuite/tests/haddock/should_fail_flag_haddock/haddockE003.stderr2
-rw-r--r--testsuite/tests/haddock/should_fail_flag_haddock/haddockE004.hs3
-rw-r--r--testsuite/tests/haddock/should_fail_flag_haddock/haddockE004.stderr2
134 files changed, 1575 insertions, 0 deletions
diff --git a/testsuite/tests/haddock/Makefile b/testsuite/tests/haddock/Makefile
new file mode 100644
index 0000000000..9a36a1c5fe
--- /dev/null
+++ b/testsuite/tests/haddock/Makefile
@@ -0,0 +1,3 @@
+TOP=../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/haddock/haddock_examples/Hidden.hs b/testsuite/tests/haddock/haddock_examples/Hidden.hs
new file mode 100644
index 0000000000..d30925b10e
--- /dev/null
+++ b/testsuite/tests/haddock/haddock_examples/Hidden.hs
@@ -0,0 +1,4 @@
+-- #hide
+module Hidden where
+hidden :: Int -> Int
+hidden a = a
diff --git a/testsuite/tests/haddock/haddock_examples/Makefile b/testsuite/tests/haddock/haddock_examples/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/haddock/haddock_examples/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/haddock/haddock_examples/Test.hs b/testsuite/tests/haddock/haddock_examples/Test.hs
new file mode 100644
index 0000000000..8336cb543d
--- /dev/null
+++ b/testsuite/tests/haddock/haddock_examples/Test.hs
@@ -0,0 +1,407 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module : Test
+-- Copyright : (c) Simon Marlow 2002
+-- License : BSD-style
+--
+-- Maintainer : libraries@haskell.org
+-- Stability : provisional
+-- Portability : portable
+--
+-- This module illustrates & tests most of the features of Haddock.
+-- Testing references from the description: 'T', 'f', 'g', 'Visible.visible'.
+--
+-----------------------------------------------------------------------------
+
+-- This is plain comment, ignored by Haddock.
+
+module Test (
+
+ -- Section headings are introduced with '-- *':
+ -- * Type declarations
+
+ -- Subsection headings are introduced with '-- **' and so on.
+ -- ** Data types
+ T(..), T2, T3(..), T4(..), T5(..), T6(..),
+ N1(..), N2(..), N3(..), N4, N5(..), N6(..), N7(..),
+
+ -- ** Records
+ R(..), R1(..),
+
+ -- | test that we can export record selectors on their own:
+ p, q, u,
+
+ -- * Class declarations
+ C(a,b), D(..), E, F(..),
+
+ -- | Test that we can export a class method on its own:
+ a,
+
+ -- * Function types
+ f, g,
+
+ -- * Auxiliary stuff
+
+ -- $aux1
+
+ -- $aux2
+
+ -- $aux3
+
+ -- $aux4
+
+ -- $aux5
+
+ -- $aux6
+
+ -- $aux7
+
+ -- $aux8
+
+ -- $aux9
+
+ -- $aux10
+
+ -- $aux11
+
+ -- $aux12
+
+ -- | This is some inline documentation in the export list
+ --
+ -- > a code block using bird-tracks
+ -- > each line must begin with > (which isn't significant unless it
+ -- > is at the beginning of the line).
+
+ -- * A hidden module
+ module Hidden,
+
+ -- * A visible module
+ module Visible,
+
+ {-| nested-style doc comments -}
+
+ -- * Existential \/ Universal types
+ Ex(..),
+
+ -- * Type signatures with argument docs
+ k, l, m, o,
+
+ -- * A section
+ -- and without an intervening comma:
+ -- ** A subsection
+
+{-|
+ > a literal line
+
+ $ a non /literal/ line $
+-}
+
+ f',
+ ) where
+
+import Hidden
+import Visible
+
+-- | This comment applies to the /following/ declaration
+-- and it continues until the next non-comment line
+data T a b
+ = A Int (Maybe Float) -- ^ This comment describes the 'A' constructor
+ | -- | This comment describes the 'B' constructor
+ B (T a b, T Int Float) -- ^
+
+-- | An abstract data declaration
+data T2 a b = T2 a b
+
+-- | A data declaration with no documentation annotations on the constructors
+data T3 a b = A1 a | B1 b
+
+-- A data declaration with no documentation annotations at all
+data T4 a b = A2 a | B2 b
+
+-- A data declaration documentation on the constructors only
+data T5 a b
+ = A3 a -- ^ documents 'A3'
+ | B3 b -- ^ documents 'B3'
+
+-- | Testing alternative comment styles
+data T6
+ -- | This is the doc for 'A4'
+ = A4
+ | B4
+ | -- ^ This is the doc for 'B4'
+
+ -- | This is the doc for 'C4'
+ C4
+
+-- | A newtype
+newtype N1 a = N1 a
+
+-- | A newtype with a fieldname
+newtype N2 a b = N2 {n :: a b}
+
+-- | A newtype with a fieldname, documentation on the field
+newtype N3 a b = N3 {n3 :: a b -- ^ this is the 'n3' field
+ }
+
+-- | An abstract newtype - we show this one as data rather than newtype because
+-- the difference isn\'t visible to the programmer for an abstract type.
+newtype N4 a b = N4 a
+
+newtype N5 a b = N5 {n5 :: a b -- ^ no docs on the datatype or the constructor
+ }
+
+newtype N6 a b = N6 {n6 :: a b
+ }
+ -- ^ docs on the constructor only
+
+-- | docs on the newtype and the constructor
+newtype N7 a b = N7 {n7 :: a b
+ }
+ -- ^ The 'N7' constructor
+
+
+class (D a) => C a where
+ -- |this is a description of the 'a' method
+ a :: IO a
+ b :: [a]
+ -- ^ this is a description of the 'b' method
+ c :: a -- c is hidden in the export list
+
+-- ^ This comment applies to the /previous/ declaration (the 'C' class)
+
+class D a where
+ d :: T a b
+ e :: (a,a)
+-- ^ This is a class declaration with no separate docs for the methods
+
+instance D Int where
+ d = undefined
+ e = undefined
+
+-- instance with a qualified class name
+instance Test.D Float where
+ d = undefined
+ e = undefined
+
+class E a where
+ ee :: a
+-- ^ This is a class declaration with no methods (or no methods exported)
+
+-- This is a class declaration with no documentation at all
+class F a where
+ ff :: a
+
+-- | This is the documentation for the 'R' record, which has four fields,
+-- 'p', 'q', 'r', and 's'.
+data R =
+ -- | This is the 'C1' record constructor, with the following fields:
+ C1 { p :: Int -- ^ This comment applies to the 'p' field
+ , q :: forall a . a->a -- ^ This comment applies to the 'q' field
+ , -- | This comment applies to both 'r' and 's'
+ r,s :: Int
+ }
+ | C2 { t :: T1 -> (T2 Int Int)-> (T3 Bool Bool) -> (T4 Float Float) -> T5 () (),
+ u,v :: Int
+ }
+ -- ^ This is the 'C2' record constructor, also with some fields:
+
+-- | Testing different record commenting styles
+data R1
+ -- | This is the 'C3' record constructor
+ = C3 {
+ -- | The 's1' record selector
+ s1 :: Int
+ -- | The 's2' record selector
+ , s2 :: Int
+ , s3 :: Int -- NOTE: In the original examples/Test.hs in Haddock, there is an extra "," here.
+ -- Since GHC doesn't allow that, I have removed it in this file.
+ -- ^ The 's3' record selector
+ }
+
+-- These section headers are only used when there is no export list to
+-- give the structure of the documentation:
+
+-- * This is a section header (level 1)
+-- ** This is a section header (level 2)
+-- *** This is a section header (level 3)
+
+{-|
+In a comment string we can refer to identifiers in scope with
+single quotes like this: 'T', and we can refer to modules by
+using double quotes: "Foo". We can add emphasis /like this/.
+
+ * This is a bulleted list
+
+ - This is the next item (different kind of bullet)
+
+ (1) This is an ordered list
+
+ 2. This is the next item (different kind of bullet)
+
+@
+ This is a block of code, which can include other markup: 'R'
+ formatting
+ is
+ significant
+@
+
+> this is another block of code
+
+We can also include URLs in documentation: <http://www.haskell.org/>.
+-}
+
+f :: C a => a -> Int
+
+-- | we can export foreign declarations too
+foreign import ccall "header.h" g :: Int -> IO CInt
+
+-- | this doc string has a parse error in it: \'
+h :: Int
+h = 42
+
+
+-- $aux1 This is some documentation that is attached to a name ($aux1)
+-- rather than a source declaration. The documentation may be
+-- referred to in the export list using its name.
+--
+-- @ code block in named doc @
+
+-- $aux2 This is some documentation that is attached to a name ($aux2)
+
+-- $aux3
+-- @ code block on its own in named doc @
+
+-- $aux4
+--
+-- @ code block on its own in named doc (after newline) @
+
+{- $aux5 a nested, named doc comment
+
+ with a paragraph,
+
+ @ and a code block @
+-}
+
+-- some tests for various arrangements of code blocks:
+
+{- $aux6
+>test
+>test1
+
+@ test2
+ test3
+@
+-}
+
+{- $aux7
+@
+test1
+test2
+@
+-}
+
+{- $aux8
+>test3
+>test4
+-}
+
+{- $aux9
+@
+test1
+test2
+@
+
+>test3
+>test4
+-}
+
+{- $aux10
+>test3
+>test4
+
+@
+test1
+test2
+@
+-}
+
+-- This one is currently wrong (Haddock 0.4). The @...@ part is
+-- interpreted as part of the bird-tracked code block.
+{- $aux11
+aux11:
+
+>test3
+>test4
+
+@
+test1
+test2
+@
+-}
+
+-- $aux12
+-- > foo
+--
+-- > bar
+--
+
+-- | A data-type using existential\/universal types
+data Ex a
+ = forall b . C b => Ex1 b
+ | forall b . Ex2 b
+ | forall b . C a => Ex3 b -- NOTE: I have added "forall b" here make GHC accept this file
+ | Ex4 (forall a . a -> a)
+
+-- | This is a function with documentation for each argument
+k :: T () () -- ^ This argument has type 'T'
+ -> (T2 Int Int) -- ^ This argument has type 'T2 Int Int'
+ -> (T3 Bool Bool -> T4 Float Float) -- ^ This argument has type @T3 Bool Bool -> T4 Float Float@
+ -> T5 () () -- ^ This argument has a very long description that should
+ -- hopefully cause some wrapping to happen when it is finally
+ -- rendered by Haddock in the generated HTML page.
+ -> IO () -- ^ This is the result type
+
+-- This function has arg docs but no docs for the function itself
+l :: (Int, Int, Float) -- ^ takes a triple
+ -> Int -- ^ returns an 'Int'
+
+-- | This function has some arg docs
+m :: R
+ -> N1 () -- ^ one of the arguments
+ -> IO Int -- ^ and the return value
+
+-- | This function has some arg docs but not a return value doc
+
+-- can't use the original name ('n') with GHC
+newn :: R -- ^ one of the arguments, an 'R'
+ -> N1 () -- ^ one of the arguments
+ -> IO Int
+newn = undefined
+
+
+-- | A foreign import with argument docs
+foreign import ccall unsafe "header.h"
+ o :: Float -- ^ The input float
+ -> IO Float -- ^ The output float
+
+-- | We should be able to escape this: \#\#\#
+
+-- p :: Int
+-- can't use the above original definition with GHC
+newp :: Int
+newp = undefined
+
+-- | a function with a prime can be referred to as 'f''
+-- but f' doesn't get link'd 'f\''
+f' :: Int
+
+
+-- Add some definitions here so that this file can be compiled with GHC
+
+data T1
+f = undefined
+f' = undefined
+type CInt = Int
+k = undefined
+l = undefined
+m = undefined
diff --git a/testsuite/tests/haddock/haddock_examples/Visible.hs b/testsuite/tests/haddock/haddock_examples/Visible.hs
new file mode 100644
index 0000000000..cad719315f
--- /dev/null
+++ b/testsuite/tests/haddock/haddock_examples/Visible.hs
@@ -0,0 +1,3 @@
+module Visible where
+visible :: Int -> Int
+visible a = a
diff --git a/testsuite/tests/haddock/haddock_examples/haddock.Test.stderr b/testsuite/tests/haddock/haddock_examples/haddock.Test.stderr
new file mode 100644
index 0000000000..ddc289f161
--- /dev/null
+++ b/testsuite/tests/haddock/haddock_examples/haddock.Test.stderr
@@ -0,0 +1,159 @@
+[1 of 3] Compiling Visible ( Visible.hs, Visible.o )
+
+==================== Parser ====================
+module Visible where
+visible :: Int -> Int
+visible a = a
+
+
+[2 of 3] Compiling Hidden ( Hidden.hs, Hidden.o )
+
+==================== Parser ====================
+module Hidden where
+hidden :: Int -> Int
+hidden a = a
+
+
+[3 of 3] Compiling Test ( Test.hs, Test.o )
+
+==================== Parser ====================
+<document comment>
+module Test (
+ <IEGroup: 1>, <IEGroup: 2>, T(..), T2, T3(..), T4(..), T5(..),
+ T6(..), N1(..), N2(..), N3(..), N4, N5(..), N6(..), N7(..),
+ <IEGroup: 2>, R(..), R1(..), <document comment>, p, q, u,
+ <IEGroup: 1>, C(a, b), D(..), E, F(..), <document comment>, a,
+ <IEGroup: 1>, f, g, <IEGroup: 1>, <IEDocNamed: aux1>,
+ <IEDocNamed: aux2>, <IEDocNamed: aux3>, <IEDocNamed: aux4>,
+ <IEDocNamed: aux5>, <IEDocNamed: aux6>, <IEDocNamed: aux7>,
+ <IEDocNamed: aux8>, <IEDocNamed: aux9>, <IEDocNamed: aux10>,
+ <IEDocNamed: aux11>, <IEDocNamed: aux12>, <document comment>,
+ <IEGroup: 1>, module Hidden, <IEGroup: 1>, module Visible,
+ <document comment>, <IEGroup: 1>, Ex(..), <IEGroup: 1>, k, l, m, o,
+ <IEGroup: 1>, <IEGroup: 2>, <document comment>, f'
+ ) where
+import Hidden
+import Visible
+<document comment>
+data T a b
+ = <document comment> A Int Maybe Float |
+ <document comment> B (T a b, T Int Float)
+<document comment>
+data T2 a b = T2 a b
+<document comment>
+data T3 a b = A1 a | B1 b
+data T4 a b = A2 a | B2 b
+data T5 a b = <document comment> A3 a | <document comment> B3 b
+<document comment>
+data T6
+ = <document comment> A4 |
+ <document comment> B4 |
+ <document comment> C4
+<document comment>
+newtype N1 a = N1 a
+<document comment>
+newtype N2 a b = N2 {n :: a b}
+<document comment>
+newtype N3 a b = N3 {n3 :: a b <document comment>}
+<document comment>
+newtype N4 a b = N4 a
+newtype N5 a b = N5 {n5 :: a b <document comment>}
+newtype N6 a b = <document comment> N6 {n6 :: a b}
+<document comment>
+newtype N7 a b = <document comment> N7 {n7 :: a b}
+class D a => C a where { a :: IO a; b :: [a]; c :: a; }
+<document comment>
+class D a where { d :: T a b; e :: (a, a); }
+<document comment>
+instance D Int where
+ { d = undefined
+ e = undefined }
+instance Test.D Float where
+ { d = undefined
+ e = undefined }
+class E a where { ee :: a; }
+<document comment>
+class F a where { ff :: a; }
+<document comment>
+data R
+ = <document comment>
+ C1 {p :: Int <document comment>,
+ q :: forall a. a -> a <document comment>,
+ r :: Int <document comment>,
+ s :: Int <document comment>} |
+ <document comment>
+ C2 {t :: T1
+ -> (T2 Int Int) -> (T3 Bool Bool) -> (T4 Float Float) -> T5 () (),
+ u :: Int,
+ v :: Int}
+<document comment>
+data R1
+ = <document comment>
+ C3 {s1 :: Int <document comment>,
+ s2 :: Int <document comment>,
+ s3 :: Int <document comment>}
+<document comment>
+<document comment>
+<document comment>
+<document comment>
+f :: C a => a -> Int
+<document comment>
+foreign import ccall safe "static header.h g" g :: Int -> IO CInt
+<document comment>
+h :: Int
+h = 42
+<document comment>
+<document comment>
+<document comment>
+<document comment>
+<document comment>
+<document comment>
+<document comment>
+<document comment>
+<document comment>
+<document comment>
+<document comment>
+<document comment>
+<document comment>
+data Ex a
+ = forall b. C b => Ex1 b |
+ forall b. Ex2 b |
+ forall b. C a => Ex3 b |
+ Ex4 forall a. a -> a
+<document comment>
+k ::
+ T () () <document comment>
+ -> (T2 Int Int) <document comment>
+ -> (T3 Bool Bool -> T4 Float Float) <document comment>
+ -> T5 () () <document comment> -> IO () <document comment>
+l :: (Int, Int, Float) <document comment> -> Int <document comment>
+<document comment>
+m :: R -> N1 () <document comment> -> IO Int <document comment>
+<document comment>
+newn :: R <document comment> -> N1 () <document comment> -> IO Int
+newn = undefined
+<document comment>
+foreign import ccall unsafe "static header.h o" o
+ :: Float <document comment> -> IO Float <document comment>
+<document comment>
+newp :: Int
+newp = undefined
+<document comment>
+f' :: Int
+data T1 =
+f = undefined
+f' = undefined
+type CInt = Int
+k = undefined
+l = undefined
+m = undefined
+
+
+
+Test.hs:32:9: Warning: `p' is exported by `p' and `R(..)'
+
+Test.hs:32:12: Warning: `q' is exported by `q' and `R(..)'
+
+Test.hs:32:15: Warning: `u' is exported by `u' and `R(..)'
+
+Test.hs:38:9: Warning: `a' is exported by `a' and `C(a, b)'
diff --git a/testsuite/tests/haddock/haddock_examples/header.h b/testsuite/tests/haddock/haddock_examples/header.h
new file mode 100644
index 0000000000..0125eb3bfd
--- /dev/null
+++ b/testsuite/tests/haddock/haddock_examples/header.h
@@ -0,0 +1,5 @@
+
+/* These are used in Test.hs */
+extern int g(HsInt x);
+extern HsFloat o(HsFloat x);
+
diff --git a/testsuite/tests/haddock/haddock_examples/test.T b/testsuite/tests/haddock/haddock_examples/test.T
new file mode 100644
index 0000000000..856bf73bfd
--- /dev/null
+++ b/testsuite/tests/haddock/haddock_examples/test.T
@@ -0,0 +1,6 @@
+test('haddock.Test',
+ [omit_ways(['optasm', 'profasm']),
+ extra_clean(['Test.hi', 'Test.o', 'Hidden.hi', 'Hidden.o',
+ 'Visible.hi', 'Visible.o'])],
+ multimod_compile,
+ ['Test Hidden Visible', '-XRank2Types -XExistentialQuantification -haddock -ddump-parsed'])
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/Makefile b/testsuite/tests/haddock/should_compile_flag_haddock/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/all.T b/testsuite/tests/haddock/should_compile_flag_haddock/all.T
new file mode 100644
index 0000000000..ed77310fd5
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/all.T
@@ -0,0 +1,33 @@
+test('haddockA001', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA002', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA003', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA004', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA005', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA006', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA007', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA008', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA009', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA010', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA011', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA012', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA013', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA014', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA015', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA016', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA017', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA018', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA019', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA020', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA021', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA022', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA023', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA024', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA025', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA026', normal, compile, ['-haddock -ddump-parsed -XRank2Types'])
+test('haddockA027', normal, compile, ['-haddock -ddump-parsed -XRank2Types'])
+test('haddockA028', normal, compile, ['-haddock -ddump-parsed -XTypeOperators'])
+test('haddockA029', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA030', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA031', normal, compile, ['-haddock -ddump-parsed -XExistentialQuantification'])
+test('haddockA032', normal, compile, ['-haddock -ddump-parsed'])
+test('haddockA033', normal, compile, ['-haddock -ddump-parsed'])
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA001.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA001.hs
new file mode 100644
index 0000000000..8710c20eee
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA001.hs
@@ -0,0 +1,5 @@
+
+module ShouldCompile where
+
+{- | blabla -}
+data Bla = Hej
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA001.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA001.stderr
new file mode 100644
index 0000000000..679876f821
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA001.stderr
@@ -0,0 +1,7 @@
+
+==================== Parser ====================
+module ShouldCompile where
+<document comment>
+data Bla = Hej
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA002.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA002.hs
new file mode 100644
index 0000000000..e6ab145eb5
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA002.hs
@@ -0,0 +1,5 @@
+
+module ShouldCompile where
+
+{- | blabla -}
+main = undefined
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA002.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA002.stderr
new file mode 100644
index 0000000000..8ad5a91566
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA002.stderr
@@ -0,0 +1,7 @@
+
+==================== Parser ====================
+module ShouldCompile where
+<document comment>
+main = undefined
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA003.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA003.hs
new file mode 100644
index 0000000000..54af6d73b4
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA003.hs
@@ -0,0 +1,5 @@
+
+module ShouldCompile where
+
+-- | blabla
+main = undefined
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA003.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA003.stderr
new file mode 100644
index 0000000000..8ad5a91566
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA003.stderr
@@ -0,0 +1,7 @@
+
+==================== Parser ====================
+module ShouldCompile where
+<document comment>
+main = undefined
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA004.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA004.hs
new file mode 100644
index 0000000000..4311798859
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA004.hs
@@ -0,0 +1,8 @@
+
+module ShouldCompile where
+
+-- | blabla öqewjlaskjfdasklöjfaslökj
+-- aslfdjaskldaskldasjda
+-- xxxxxx
+-- end of the comment
+main = undefined
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA004.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA004.stderr
new file mode 100644
index 0000000000..8ad5a91566
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA004.stderr
@@ -0,0 +1,7 @@
+
+==================== Parser ====================
+module ShouldCompile where
+<document comment>
+main = undefined
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA005.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA005.hs
new file mode 100644
index 0000000000..4c854505ca
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA005.hs
@@ -0,0 +1,4 @@
+hej = undefined
+
+-- | 1l3i1j3 as
+main = undefined
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA005.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA005.stderr
new file mode 100644
index 0000000000..8fced3ae43
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA005.stderr
@@ -0,0 +1,7 @@
+
+==================== Parser ====================
+hej = undefined
+<document comment>
+main = undefined
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA006.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA006.hs
new file mode 100644
index 0000000000..518c598b38
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA006.hs
@@ -0,0 +1,6 @@
+{-^ wealwwwwwwwwwwww
+
+
+-}
+main = return ()
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA006.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA006.stderr
new file mode 100644
index 0000000000..43971dfd1d
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA006.stderr
@@ -0,0 +1,6 @@
+
+==================== Parser ====================
+<document comment>
+main = return ()
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA007.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA007.hs
new file mode 100644
index 0000000000..c6098072bf
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA007.hs
@@ -0,0 +1,5 @@
+
+module ShouldCompile where
+
+{- |asd-}
+main=undefined
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA007.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA007.stderr
new file mode 100644
index 0000000000..8ad5a91566
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA007.stderr
@@ -0,0 +1,7 @@
+
+==================== Parser ====================
+module ShouldCompile where
+<document comment>
+main = undefined
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA008.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA008.hs
new file mode 100644
index 0000000000..ca17e8de4b
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA008.hs
@@ -0,0 +1,7 @@
+
+module ShouldCompile where
+
+{-|
+main=undefined
+-}
+main = undefined
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA008.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA008.stderr
new file mode 100644
index 0000000000..8ad5a91566
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA008.stderr
@@ -0,0 +1,7 @@
+
+==================== Parser ====================
+module ShouldCompile where
+<document comment>
+main = undefined
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA009.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA009.hs
new file mode 100644
index 0000000000..67ef8ff570
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA009.hs
@@ -0,0 +1,5 @@
+
+module ShouldCompile where
+
+{-$ aslkdjasasd asdkjasdlaj {-weqw -}-}
+main = undefined
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA009.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA009.stderr
new file mode 100644
index 0000000000..8ad5a91566
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA009.stderr
@@ -0,0 +1,7 @@
+
+==================== Parser ====================
+module ShouldCompile where
+<document comment>
+main = undefined
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA010.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA010.hs
new file mode 100644
index 0000000000..943b28e485
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA010.hs
@@ -0,0 +1,5 @@
+
+module ShouldCompile where
+
+{-| weoprjwer {- | qwoiejqwioe -}-}
+main = undefined
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA010.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA010.stderr
new file mode 100644
index 0000000000..8ad5a91566
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA010.stderr
@@ -0,0 +1,7 @@
+
+==================== Parser ====================
+module ShouldCompile where
+<document comment>
+main = undefined
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA011.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA011.hs
new file mode 100644
index 0000000000..5efa2db249
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA011.hs
@@ -0,0 +1,8 @@
+
+module ShouldCompile where
+
+-- aslkdjasldkjasldkaj
+-- | awlkdajsads
+-- asdasödlklas
+--qww
+main=undefined
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA011.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA011.stderr
new file mode 100644
index 0000000000..8ad5a91566
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA011.stderr
@@ -0,0 +1,7 @@
+
+==================== Parser ====================
+module ShouldCompile where
+<document comment>
+main = undefined
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA012.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA012.hs
new file mode 100644
index 0000000000..c392d85211
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA012.hs
@@ -0,0 +1,11 @@
+
+main=undefined
+
+-- | vkfja
+hej=main
+-- | ieasdkjahsdkjashd
+x = hej
+
+
+-- | eroiewuroieuwr
+y = undefined
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA012.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA012.stderr
new file mode 100644
index 0000000000..56736ccbca
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA012.stderr
@@ -0,0 +1,11 @@
+
+==================== Parser ====================
+main = undefined
+<document comment>
+hej = main
+<document comment>
+x = hej
+<document comment>
+y = undefined
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA013.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA013.hs
new file mode 100644
index 0000000000..224e38d360
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA013.hs
@@ -0,0 +1,13 @@
+module ShouldCompile where
+
+-- ^ bla
+main=undefined
+
+-- ^ vkfja
+hej=main
+-- ^ ieasdkjahsdkjashd
+x = hej
+
+
+-- ^ eroiewuroieuwr
+y = undefined
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA013.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA013.stderr
new file mode 100644
index 0000000000..ea9837b3c8
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA013.stderr
@@ -0,0 +1,13 @@
+
+==================== Parser ====================
+module ShouldCompile where
+<document comment>
+main = undefined
+<document comment>
+hej = main
+<document comment>
+x = hej
+<document comment>
+y = undefined
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA014.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA014.hs
new file mode 100644
index 0000000000..880264f60b
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA014.hs
@@ -0,0 +1,5 @@
+-- | a header
+module HeaderTest where
+
+-- | bla bla
+x = 0
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA014.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA014.stderr
new file mode 100644
index 0000000000..f71f89a89e
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA014.stderr
@@ -0,0 +1,8 @@
+
+==================== Parser ====================
+<document comment>
+module HeaderTest where
+<document comment>
+x = 0
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA015.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA015.hs
new file mode 100644
index 0000000000..b4b47be108
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA015.hs
@@ -0,0 +1,14 @@
+-- | a header
+module HeaderTest where
+
+-- * A section
+x = 0
+
+-- ** A subsection
+y = 1
+
+-- *** A subsubsection
+main = print x
+
+-- | bla bla
+z = 0
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA015.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA015.stderr
new file mode 100644
index 0000000000..356d5b73bf
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA015.stderr
@@ -0,0 +1,14 @@
+
+==================== Parser ====================
+<document comment>
+module HeaderTest where
+<document comment>
+x = 0
+<document comment>
+y = 1
+<document comment>
+main = print x
+<document comment>
+z = 0
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA016.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA016.hs
new file mode 100644
index 0000000000..ffe02923ea
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA016.hs
@@ -0,0 +1,4 @@
+-- #hide, prune, ignore-exports
+
+-- |Module description
+module A where
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA016.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA016.stderr
new file mode 100644
index 0000000000..1f436a7bec
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA016.stderr
@@ -0,0 +1,6 @@
+
+==================== Parser ====================
+<document comment>
+module A where
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA017.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA017.hs
new file mode 100644
index 0000000000..75d859a1c7
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA017.hs
@@ -0,0 +1,2 @@
+-- #hide, prune, ignore-exports
+module A where
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA017.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA017.stderr
new file mode 100644
index 0000000000..3fd476b166
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA017.stderr
@@ -0,0 +1,5 @@
+
+==================== Parser ====================
+module A where
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA018.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA018.hs
new file mode 100644
index 0000000000..c8b6f52d42
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA018.hs
@@ -0,0 +1,4 @@
+-- | module header bla bla
+
+-- #hide, prune, ignore-exports
+module A where
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA018.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA018.stderr
new file mode 100644
index 0000000000..1f436a7bec
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA018.stderr
@@ -0,0 +1,6 @@
+
+==================== Parser ====================
+<document comment>
+module A where
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA019.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA019.hs
new file mode 100644
index 0000000000..7e5e98be8d
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA019.hs
@@ -0,0 +1,7 @@
+module A (
+
+-- | bla bla
+
+{- | blabla -}
+
+) where
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA019.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA019.stderr
new file mode 100644
index 0000000000..68e7b4f225
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA019.stderr
@@ -0,0 +1,7 @@
+
+==================== Parser ====================
+module A (
+ <document comment>, <document comment>
+ ) where
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA020.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA020.hs
new file mode 100644
index 0000000000..31b38da179
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA020.hs
@@ -0,0 +1,15 @@
+module A (
+
+-- | bla bla
+
+{- | blabla -}
+
+x,
+
+-- ** qeöqwkeöwqlkeqöle
+
+-- | qweljqwelkqjwelqjkq
+
+) where
+
+x = True
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA020.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA020.stderr
new file mode 100644
index 0000000000..20c628006d
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA020.stderr
@@ -0,0 +1,8 @@
+
+==================== Parser ====================
+module A (
+ <document comment>, <document comment>, x, <IEGroup: 2>, <document comment>
+ ) where
+x = True
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA021.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA021.hs
new file mode 100644
index 0000000000..ac12f30d6b
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA021.hs
@@ -0,0 +1,25 @@
+module A (
+
+-- | bla bla
+
+{- | blabla -}
+
+x,
+
+-- ** qeöqwkeöwqlkeqöle
+
+-- | qweljqwelkqjwelqjkq
+
+y,
+
+
+-- | dkashdakj
+z
+
+-- * asdjha
+
+) where
+
+x = True
+y = False
+z = True
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA021.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA021.stderr
new file mode 100644
index 0000000000..edf523dfa2
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA021.stderr
@@ -0,0 +1,11 @@
+
+==================== Parser ====================
+module A (
+ <document comment>, <document comment>, x, <IEGroup: 2>, <document comment>, y,
+ <document comment>, z, <IEGroup: 1>
+ ) where
+x = True
+y = False
+z = True
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA022.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA022.hs
new file mode 100644
index 0000000000..dcd90750e0
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA022.hs
@@ -0,0 +1,11 @@
+
+main = print (test::Int)
+ where
+ -- | kjfhaskd
+ test = 0
+ -- | xzczn
+ -- qwelkjqwelkqj
+ test2 = 1
+
+ -- | adlkjadajdldjad
+ test3 = 2
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA022.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA022.stderr
new file mode 100644
index 0000000000..6e6c5c6730
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA022.stderr
@@ -0,0 +1,9 @@
+
+==================== Parser ====================
+main = print (test :: Int)
+ where
+ test = 0
+ test2 = 1
+ test3 = 2
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA023.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA023.hs
new file mode 100644
index 0000000000..e197a6b48f
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA023.hs
@@ -0,0 +1,6 @@
+module ShouldCompile where
+
+test :: (Eq a) => [a] -- ^ doc1
+ -> [a] {-^ doc2 -}
+ -> [a] -- ^ doc3
+test xs ys = xs
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA023.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA023.stderr
new file mode 100644
index 0000000000..2c4f5bc952
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA023.stderr
@@ -0,0 +1,10 @@
+
+==================== Parser ====================
+module ShouldCompile where
+test ::
+ Eq a =>
+ [a] <document comment>
+ -> [a] <document comment> -> [a] <document comment>
+test xs ys = xs
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA024.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA024.hs
new file mode 100644
index 0000000000..9e069c322c
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA024.hs
@@ -0,0 +1,5 @@
+module ShouldCompile where
+
+test2 :: a -- ^ doc1
+ -> b {-^ doc2 -} -> a -- ^ doc 3
+test2 x y = x
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA024.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA024.stderr
new file mode 100644
index 0000000000..f0d269d0b1
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA024.stderr
@@ -0,0 +1,7 @@
+
+==================== Parser ====================
+module ShouldCompile where
+test2 :: a <document comment> -> b <document comment> -> a <document comment>
+test2 x y = x
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA025.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA025.hs
new file mode 100644
index 0000000000..c53ae7bb3e
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA025.hs
@@ -0,0 +1,5 @@
+module ShouldCompile where
+
+test2 :: a -- ^ doc1
+ -> a
+test2 x = x
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA025.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA025.stderr
new file mode 100644
index 0000000000..792da55155
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA025.stderr
@@ -0,0 +1,7 @@
+
+==================== Parser ====================
+module ShouldCompile where
+test2 :: a <document comment> -> a
+test2 x = x
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA026.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA026.hs
new file mode 100644
index 0000000000..cc2d8bfae5
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA026.hs
@@ -0,0 +1,6 @@
+module ShouldCompile where
+
+test :: (Eq a) => [a] -- ^ doc1
+ -> forall b . [b] {-^ doc2 -}
+ -> [a] -- ^ doc3
+test xs ys = xs
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA026.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA026.stderr
new file mode 100644
index 0000000000..e352980fd4
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA026.stderr
@@ -0,0 +1,10 @@
+
+==================== Parser ====================
+module ShouldCompile where
+test ::
+ Eq a =>
+ [a] <document comment>
+ -> forall b. [b] <document comment> -> [a] <document comment>
+test xs ys = xs
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA027.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA027.hs
new file mode 100644
index 0000000000..1aa6e37d07
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA027.hs
@@ -0,0 +1,7 @@
+module ShouldCompile where
+
+test :: [a] -- ^ doc1
+ -> forall b. (Ord b) => [b] {-^ doc2 -}
+ -> forall c. (Num c) => [c] -- ^ doc3
+ -> [a]
+test xs ys zs = xs
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA027.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA027.stderr
new file mode 100644
index 0000000000..67bf6528c0
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA027.stderr
@@ -0,0 +1,11 @@
+
+==================== Parser ====================
+module ShouldCompile where
+test ::
+ [a] <document comment>
+ -> forall b. Ord b =>
+ [b] <document comment>
+ -> forall c. Num c => [c] <document comment> -> [a]
+test xs ys zs = xs
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA028.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA028.hs
new file mode 100644
index 0000000000..2f4b7c1bcb
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA028.hs
@@ -0,0 +1,6 @@
+module ShouldCompile where
+
+test :: [a] -- ^ doc1
+ -> a <--> b
+ -> [a] -- ^ blabla
+test xs ys = xs
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA028.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA028.stderr
new file mode 100644
index 0000000000..d74422461e
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA028.stderr
@@ -0,0 +1,8 @@
+
+==================== Parser ====================
+module ShouldCompile where
+test ::
+ [a] <document comment> -> (a <--> (b -> [a])) <document comment>
+test xs ys = xs
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA029.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA029.hs
new file mode 100644
index 0000000000..2615e555f1
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA029.hs
@@ -0,0 +1,5 @@
+module ShouldCompile where
+
+data A
+ -- | A comment that documents the first constructor
+ = A | B | C | D
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA029.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA029.stderr
new file mode 100644
index 0000000000..aa48d998ef
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA029.stderr
@@ -0,0 +1,6 @@
+
+==================== Parser ====================
+module ShouldCompile where
+data A = <document comment> A | B | C | D
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA030.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA030.hs
new file mode 100644
index 0000000000..82c3799d1f
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA030.hs
@@ -0,0 +1,10 @@
+module ShouldCompile where
+
+data A
+ -- | A comment that documents the first constructor
+ = A
+ -- | comment for B
+ | {-^ comment for A -} B
+ -- | comment for C
+ | C
+ | D
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA030.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA030.stderr
new file mode 100644
index 0000000000..c879d2244b
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA030.stderr
@@ -0,0 +1,6 @@
+
+==================== Parser ====================
+module ShouldCompile where
+data A = <document comment> A | <document comment> B | <document comment> C | D
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA031.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA031.hs
new file mode 100644
index 0000000000..2d4b55f659
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA031.hs
@@ -0,0 +1,6 @@
+module ShouldCompile where
+
+data A
+ = A
+ | {-| comment for B -} forall a. B a a
+ | forall a. Num a => C a {-^ comment for C -}
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA031.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA031.stderr
new file mode 100644
index 0000000000..75ac2945b8
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA031.stderr
@@ -0,0 +1,9 @@
+
+==================== Parser ====================
+module ShouldCompile where
+data A
+ = A |
+ <document comment> forall a. B a a |
+ <document comment> forall a. Num a => C a
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA032.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA032.hs
new file mode 100644
index 0000000000..b772ec1de3
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA032.hs
@@ -0,0 +1,8 @@
+module ShouldCompile where
+
+data R a = R {
+ field1 :: a -- | comment for field2
+ , field2 :: a
+ , field3 :: a -- ^ comment for field3
+ , {-| comment for field4 -} field4 :: a
+}
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA032.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA032.stderr
new file mode 100644
index 0000000000..2b0e4d24af
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA032.stderr
@@ -0,0 +1,10 @@
+
+==================== Parser ====================
+module ShouldCompile where
+data R a
+ = R {field1 :: a,
+ field2 :: a <document comment>,
+ field3 :: a <document comment>,
+ field4 :: a <document comment>}
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA033.hs b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA033.hs
new file mode 100644
index 0000000000..6d3db6cdc6
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA033.hs
@@ -0,0 +1,11 @@
+module ShouldCompile where
+
+-- | dlkjasldkja
+f 0 = 1
+-- | falkajflksjfa
+f 1 = 2
+-- | slkdjasldkj
+f 3 = 6
+-- | asldfaslödjas
+
+-- | blabla
diff --git a/testsuite/tests/haddock/should_compile_flag_haddock/haddockA033.stderr b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA033.stderr
new file mode 100644
index 0000000000..c1760c11fe
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_haddock/haddockA033.stderr
@@ -0,0 +1,11 @@
+
+==================== Parser ====================
+module ShouldCompile where
+<document comment>
+f 0 = 1
+f 1 = 2
+f 3 = 6
+<document comment>
+<document comment>
+
+
diff --git a/testsuite/tests/haddock/should_compile_flag_nohaddock/Makefile b/testsuite/tests/haddock/should_compile_flag_nohaddock/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_nohaddock/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/haddock/should_compile_flag_nohaddock/all.T b/testsuite/tests/haddock/should_compile_flag_nohaddock/all.T
new file mode 100644
index 0000000000..500a7e6bd1
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_nohaddock/all.T
@@ -0,0 +1,4 @@
+test('haddockB001', normal, compile, [''])
+test('haddockB002', normal, compile, [''])
+test('haddockB003', normal, compile, [''])
+test('haddockB004', normal, compile, [''])
diff --git a/testsuite/tests/haddock/should_compile_flag_nohaddock/haddockB001.hs b/testsuite/tests/haddock/should_compile_flag_nohaddock/haddockB001.hs
new file mode 100644
index 0000000000..10998fdb1d
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_nohaddock/haddockB001.hs
@@ -0,0 +1,3 @@
+
+{- xc,zxcz -}
+main = putStrLn "hej"
diff --git a/testsuite/tests/haddock/should_compile_flag_nohaddock/haddockB002.hs b/testsuite/tests/haddock/should_compile_flag_nohaddock/haddockB002.hs
new file mode 100644
index 0000000000..f698fa0520
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_nohaddock/haddockB002.hs
@@ -0,0 +1,3 @@
+{-{--}-}
+
+main=return()
diff --git a/testsuite/tests/haddock/should_compile_flag_nohaddock/haddockB003.hs b/testsuite/tests/haddock/should_compile_flag_nohaddock/haddockB003.hs
new file mode 100644
index 0000000000..7c3f733483
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_nohaddock/haddockB003.hs
@@ -0,0 +1,2 @@
+----------------------------------------------------------
+main = undefined
diff --git a/testsuite/tests/haddock/should_compile_flag_nohaddock/haddockB004.hs b/testsuite/tests/haddock/should_compile_flag_nohaddock/haddockB004.hs
new file mode 100644
index 0000000000..cc9e07e6b2
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_flag_nohaddock/haddockB004.hs
@@ -0,0 +1,17 @@
+{-# OPTIONS_GHC -XNoImplicitPrelude #-}
+-----------------------------------------------------------------------------
+--
+-- Module : Foreign
+-- Copyright : (c) The FFI task force 2001
+-- License : BSD-style (see the file libraries/base/LICENSE)
+--
+-- Maintainer : ffi@haskell.org
+-- Stability : provisional
+-- Portability : portable
+--
+-- A collection of data types, classes, and functions for interfacing
+-- with another programming language.
+--
+-----------------------------------------------------------------------------
+
+module Hej where
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/Makefile b/testsuite/tests/haddock/should_compile_noflag_haddock/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/all.T b/testsuite/tests/haddock/should_compile_noflag_haddock/all.T
new file mode 100644
index 0000000000..dbc7d17d9a
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/all.T
@@ -0,0 +1,33 @@
+test('haddockC001', normal, compile, [''])
+test('haddockC002', normal, compile, [''])
+test('haddockC003', normal, compile, [''])
+test('haddockC004', normal, compile, [''])
+test('haddockC005', normal, compile, [''])
+test('haddockC006', normal, compile, [''])
+test('haddockC007', normal, compile, [''])
+test('haddockC008', normal, compile, [''])
+test('haddockC009', normal, compile, [''])
+test('haddockC010', normal, compile, [''])
+test('haddockC011', normal, compile, [''])
+test('haddockC012', normal, compile, [''])
+test('haddockC013', normal, compile, [''])
+test('haddockC014', normal, compile, [''])
+test('haddockC015', normal, compile, [''])
+test('haddockC016', normal, compile, [''])
+test('haddockC017', normal, compile, [''])
+test('haddockC018', normal, compile, [''])
+test('haddockC019', normal, compile, [''])
+test('haddockC020', normal, compile, [''])
+test('haddockC021', normal, compile, [''])
+test('haddockC022', normal, compile, [''])
+test('haddockC023', normal, compile, [''])
+test('haddockC024', normal, compile, [''])
+test('haddockC025', normal, compile, [''])
+test('haddockC026', normal, compile, ['-XRank2Types'])
+test('haddockC027', normal, compile, ['-XRank2Types'])
+test('haddockC028', normal, compile, ['-XTypeOperators'])
+test('haddockC029', normal, compile, [''])
+test('haddockC030', normal, compile, [''])
+test('haddockC031', normal, compile, ['-XExistentialQuantification'])
+test('haddockC032', normal, compile, [''])
+test('haddockSimplUtilsBug', normal, compile, [''])
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC001.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC001.hs
new file mode 100644
index 0000000000..8710c20eee
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC001.hs
@@ -0,0 +1,5 @@
+
+module ShouldCompile where
+
+{- | blabla -}
+data Bla = Hej
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC002.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC002.hs
new file mode 100644
index 0000000000..e6ab145eb5
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC002.hs
@@ -0,0 +1,5 @@
+
+module ShouldCompile where
+
+{- | blabla -}
+main = undefined
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC003.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC003.hs
new file mode 100644
index 0000000000..54af6d73b4
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC003.hs
@@ -0,0 +1,5 @@
+
+module ShouldCompile where
+
+-- | blabla
+main = undefined
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC004.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC004.hs
new file mode 100644
index 0000000000..4311798859
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC004.hs
@@ -0,0 +1,8 @@
+
+module ShouldCompile where
+
+-- | blabla öqewjlaskjfdasklöjfaslökj
+-- aslfdjaskldaskldasjda
+-- xxxxxx
+-- end of the comment
+main = undefined
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC005.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC005.hs
new file mode 100644
index 0000000000..4c854505ca
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC005.hs
@@ -0,0 +1,4 @@
+hej = undefined
+
+-- | 1l3i1j3 as
+main = undefined
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC006.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC006.hs
new file mode 100644
index 0000000000..518c598b38
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC006.hs
@@ -0,0 +1,6 @@
+{-^ wealwwwwwwwwwwww
+
+
+-}
+main = return ()
+
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC007.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC007.hs
new file mode 100644
index 0000000000..94ce040c20
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC007.hs
@@ -0,0 +1,5 @@
+
+module ShouldCompiler where
+
+{- |asd-}
+main=undefined
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC008.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC008.hs
new file mode 100644
index 0000000000..ca17e8de4b
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC008.hs
@@ -0,0 +1,7 @@
+
+module ShouldCompile where
+
+{-|
+main=undefined
+-}
+main = undefined
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC009.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC009.hs
new file mode 100644
index 0000000000..67ef8ff570
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC009.hs
@@ -0,0 +1,5 @@
+
+module ShouldCompile where
+
+{-$ aslkdjasasd asdkjasdlaj {-weqw -}-}
+main = undefined
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC010.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC010.hs
new file mode 100644
index 0000000000..943b28e485
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC010.hs
@@ -0,0 +1,5 @@
+
+module ShouldCompile where
+
+{-| weoprjwer {- | qwoiejqwioe -}-}
+main = undefined
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC011.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC011.hs
new file mode 100644
index 0000000000..c6146d2369
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC011.hs
@@ -0,0 +1,8 @@
+
+module ShouldCompile where
+
+-- aslkdjasldkjasldkaj
+-- | awlkdajsads
+---asdasödlklas
+--------------- qww
+main=undefined
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC012.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC012.hs
new file mode 100644
index 0000000000..c392d85211
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC012.hs
@@ -0,0 +1,11 @@
+
+main=undefined
+
+-- | vkfja
+hej=main
+-- | ieasdkjahsdkjashd
+x = hej
+
+
+-- | eroiewuroieuwr
+y = undefined
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC013.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC013.hs
new file mode 100644
index 0000000000..82f2561f86
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC013.hs
@@ -0,0 +1,14 @@
+
+module ShouldCompile where
+
+-- ^ bla
+main=undefined
+
+-- ^ vkfja
+hej=main
+-- ^ ieasdkjahsdkjashd
+x = hej
+
+
+-- ^ eroiewuroieuwr
+y = undefined
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC014.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC014.hs
new file mode 100644
index 0000000000..880264f60b
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC014.hs
@@ -0,0 +1,5 @@
+-- | a header
+module HeaderTest where
+
+-- | bla bla
+x = 0
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC015.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC015.hs
new file mode 100644
index 0000000000..b4b47be108
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC015.hs
@@ -0,0 +1,14 @@
+-- | a header
+module HeaderTest where
+
+-- * A section
+x = 0
+
+-- ** A subsection
+y = 1
+
+-- *** A subsubsection
+main = print x
+
+-- | bla bla
+z = 0
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC016.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC016.hs
new file mode 100644
index 0000000000..ffe02923ea
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC016.hs
@@ -0,0 +1,4 @@
+-- #hide, prune, ignore-exports
+
+-- |Module description
+module A where
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC017.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC017.hs
new file mode 100644
index 0000000000..75d859a1c7
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC017.hs
@@ -0,0 +1,2 @@
+-- #hide, prune, ignore-exports
+module A where
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC018.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC018.hs
new file mode 100644
index 0000000000..c8b6f52d42
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC018.hs
@@ -0,0 +1,4 @@
+-- | module header bla bla
+
+-- #hide, prune, ignore-exports
+module A where
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC019.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC019.hs
new file mode 100644
index 0000000000..7e5e98be8d
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC019.hs
@@ -0,0 +1,7 @@
+module A (
+
+-- | bla bla
+
+{- | blabla -}
+
+) where
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC020.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC020.hs
new file mode 100644
index 0000000000..31b38da179
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC020.hs
@@ -0,0 +1,15 @@
+module A (
+
+-- | bla bla
+
+{- | blabla -}
+
+x,
+
+-- ** qeöqwkeöwqlkeqöle
+
+-- | qweljqwelkqjwelqjkq
+
+) where
+
+x = True
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC021.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC021.hs
new file mode 100644
index 0000000000..ac12f30d6b
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC021.hs
@@ -0,0 +1,25 @@
+module A (
+
+-- | bla bla
+
+{- | blabla -}
+
+x,
+
+-- ** qeöqwkeöwqlkeqöle
+
+-- | qweljqwelkqjwelqjkq
+
+y,
+
+
+-- | dkashdakj
+z
+
+-- * asdjha
+
+) where
+
+x = True
+y = False
+z = True
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC022.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC022.hs
new file mode 100644
index 0000000000..dcd90750e0
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC022.hs
@@ -0,0 +1,11 @@
+
+main = print (test::Int)
+ where
+ -- | kjfhaskd
+ test = 0
+ -- | xzczn
+ -- qwelkjqwelkqj
+ test2 = 1
+
+ -- | adlkjadajdldjad
+ test3 = 2
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC023.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC023.hs
new file mode 100644
index 0000000000..9e069c322c
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC023.hs
@@ -0,0 +1,5 @@
+module ShouldCompile where
+
+test2 :: a -- ^ doc1
+ -> b {-^ doc2 -} -> a -- ^ doc 3
+test2 x y = x
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC024.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC024.hs
new file mode 100644
index 0000000000..9e069c322c
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC024.hs
@@ -0,0 +1,5 @@
+module ShouldCompile where
+
+test2 :: a -- ^ doc1
+ -> b {-^ doc2 -} -> a -- ^ doc 3
+test2 x y = x
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC025.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC025.hs
new file mode 100644
index 0000000000..c53ae7bb3e
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC025.hs
@@ -0,0 +1,5 @@
+module ShouldCompile where
+
+test2 :: a -- ^ doc1
+ -> a
+test2 x = x
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC026.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC026.hs
new file mode 100644
index 0000000000..cc2d8bfae5
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC026.hs
@@ -0,0 +1,6 @@
+module ShouldCompile where
+
+test :: (Eq a) => [a] -- ^ doc1
+ -> forall b . [b] {-^ doc2 -}
+ -> [a] -- ^ doc3
+test xs ys = xs
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC027.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC027.hs
new file mode 100644
index 0000000000..c22be2fb87
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC027.hs
@@ -0,0 +1,21 @@
+module ShouldCompile where
+
+-- I bet this test is a mistake! From the layout it
+-- looks as if 'test' takes three args, the latter two
+-- of higher rank. But the parens around these args are
+-- missing, so it parses as
+-- test :: [a]
+-- -> forall a. Ord a
+-- => [b]
+-- -> forall c. Num c
+-- => [c]
+-- -> [a]
+--
+-- But maybe that what was intended; I'm not sure
+-- Anyway it should typecheck!
+
+test :: [a] -- ^ doc1
+ -> forall b. (Ord b) => [b] {-^ doc2 -}
+ -> forall c. (Num c) => [c] -- ^ doc3
+ -> [a]
+test xs ys zs = xs
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC028.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC028.hs
new file mode 100644
index 0000000000..3f8abc19d3
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC028.hs
@@ -0,0 +1,6 @@
+module ShouldCompile where
+
+test :: [a] -- ^ doc1
+ -> a <--> b
+ -> [a] -- ^ doc3
+test xs ys = xs
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC029.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC029.hs
new file mode 100644
index 0000000000..2615e555f1
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC029.hs
@@ -0,0 +1,5 @@
+module ShouldCompile where
+
+data A
+ -- | A comment that documents the first constructor
+ = A | B | C | D
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC030.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC030.hs
new file mode 100644
index 0000000000..82c3799d1f
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC030.hs
@@ -0,0 +1,10 @@
+module ShouldCompile where
+
+data A
+ -- | A comment that documents the first constructor
+ = A
+ -- | comment for B
+ | {-^ comment for A -} B
+ -- | comment for C
+ | C
+ | D
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC031.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC031.hs
new file mode 100644
index 0000000000..2d4b55f659
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC031.hs
@@ -0,0 +1,6 @@
+module ShouldCompile where
+
+data A
+ = A
+ | {-| comment for B -} forall a. B a a
+ | forall a. Num a => C a {-^ comment for C -}
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC032.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC032.hs
new file mode 100644
index 0000000000..b772ec1de3
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockC032.hs
@@ -0,0 +1,8 @@
+module ShouldCompile where
+
+data R a = R {
+ field1 :: a -- | comment for field2
+ , field2 :: a
+ , field3 :: a -- ^ comment for field3
+ , {-| comment for field4 -} field4 :: a
+}
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockSimplUtilsBug.hs b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockSimplUtilsBug.hs
new file mode 100644
index 0000000000..a62020f508
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockSimplUtilsBug.hs
@@ -0,0 +1,44 @@
+module ShouldCompile where
+
+postInlineUnconditionally
+ = case Just "Hey" of
+ -- The point of examining occ_info here is that for *non-values*
+ -- that occur outside a lambda, the call-site inliner won't have
+ -- a chance (becuase it doesn't know that the thing
+ -- only occurs once). The pre-inliner won't have gotten
+ -- it either, if the thing occurs in more than one branch
+ -- So the main target is things like
+ -- let x = f y in
+ -- case v of
+ -- True -> case x of ...
+ -- False -> case x of ...
+ -- I'm not sure how important this is in practice
+ Just a -- OneOcc => no work-duplication issue
+ -> True -- Small enough to dup
+ -- ToDo: consider discount on smallEnoughToInline if int_cxt is true
+ --
+ -- NB: Do NOT inline arbitrarily big things, even if one_br is True
+ -- Reason: doing so risks exponential behaviour. We simplify a big
+ -- expression, inline it, and simplify it again. But if the
+ -- very same thing happens in the big expression, we get
+ -- exponential cost!
+ -- PRINCIPLE: when we've already simplified an expression once,
+ -- make sure that we only inline it if it's reasonably small.
+
+ _ -> False
+
+-- Here's an example that we don't handle well:
+-- let f = if b then Left (\x.BIG) else Right (\y.BIG)
+-- in \y. ....case f of {...} ....
+-- Here f is used just once, and duplicating the case work is fine (exprIsCheap).
+-- But
+-- * We can't preInlineUnconditionally because that woud invalidate
+-- the occ info for b.
+-- * We can't postInlineUnconditionally because the RHS is big, and
+-- that risks exponential behaviour
+-- * We can't call-site inline, because the rhs is big
+-- Alas!
+
+ where
+ x = id
+
diff --git a/testsuite/tests/haddock/should_compile_noflag_haddock/haddockSimplUtilsBug.stderr b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockSimplUtilsBug.stderr
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_haddock/haddockSimplUtilsBug.stderr
diff --git a/testsuite/tests/haddock/should_compile_noflag_nohaddock/Makefile b/testsuite/tests/haddock/should_compile_noflag_nohaddock/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_nohaddock/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/haddock/should_compile_noflag_nohaddock/all.T b/testsuite/tests/haddock/should_compile_noflag_nohaddock/all.T
new file mode 100644
index 0000000000..89c205b3ce
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_nohaddock/all.T
@@ -0,0 +1,4 @@
+test('haddockD001', normal, compile, [''])
+test('haddockD002', normal, compile, [''])
+test('haddockD003', normal, compile, [''])
+test('haddockD004', normal, compile, [''])
diff --git a/testsuite/tests/haddock/should_compile_noflag_nohaddock/haddockD001.hs b/testsuite/tests/haddock/should_compile_noflag_nohaddock/haddockD001.hs
new file mode 100644
index 0000000000..10998fdb1d
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_nohaddock/haddockD001.hs
@@ -0,0 +1,3 @@
+
+{- xc,zxcz -}
+main = putStrLn "hej"
diff --git a/testsuite/tests/haddock/should_compile_noflag_nohaddock/haddockD002.hs b/testsuite/tests/haddock/should_compile_noflag_nohaddock/haddockD002.hs
new file mode 100644
index 0000000000..f698fa0520
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_nohaddock/haddockD002.hs
@@ -0,0 +1,3 @@
+{-{--}-}
+
+main=return()
diff --git a/testsuite/tests/haddock/should_compile_noflag_nohaddock/haddockD003.hs b/testsuite/tests/haddock/should_compile_noflag_nohaddock/haddockD003.hs
new file mode 100644
index 0000000000..7c3f733483
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_nohaddock/haddockD003.hs
@@ -0,0 +1,2 @@
+----------------------------------------------------------
+main = undefined
diff --git a/testsuite/tests/haddock/should_compile_noflag_nohaddock/haddockD004.hs b/testsuite/tests/haddock/should_compile_noflag_nohaddock/haddockD004.hs
new file mode 100644
index 0000000000..cc9e07e6b2
--- /dev/null
+++ b/testsuite/tests/haddock/should_compile_noflag_nohaddock/haddockD004.hs
@@ -0,0 +1,17 @@
+{-# OPTIONS_GHC -XNoImplicitPrelude #-}
+-----------------------------------------------------------------------------
+--
+-- Module : Foreign
+-- Copyright : (c) The FFI task force 2001
+-- License : BSD-style (see the file libraries/base/LICENSE)
+--
+-- Maintainer : ffi@haskell.org
+-- Stability : provisional
+-- Portability : portable
+--
+-- A collection of data types, classes, and functions for interfacing
+-- with another programming language.
+--
+-----------------------------------------------------------------------------
+
+module Hej where
diff --git a/testsuite/tests/haddock/should_fail_flag_haddock/Makefile b/testsuite/tests/haddock/should_fail_flag_haddock/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/haddock/should_fail_flag_haddock/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/haddock/should_fail_flag_haddock/all.T b/testsuite/tests/haddock/should_fail_flag_haddock/all.T
new file mode 100644
index 0000000000..bbe4c6edf2
--- /dev/null
+++ b/testsuite/tests/haddock/should_fail_flag_haddock/all.T
@@ -0,0 +1,4 @@
+#test('haddockE001', normal, compile_fail, ['-haddock'])
+#test('haddockE002', normal, compile_fail, ['-haddock'])
+#test('haddockE003', normal, compile_fail, ['-haddock'])
+test('haddockE004', normal, compile_fail, ['-haddock'])
diff --git a/testsuite/tests/haddock/should_fail_flag_haddock/haddockE001.hs b/testsuite/tests/haddock/should_fail_flag_haddock/haddockE001.hs
new file mode 100644
index 0000000000..b8d900190a
--- /dev/null
+++ b/testsuite/tests/haddock/should_fail_flag_haddock/haddockE001.hs
@@ -0,0 +1,2 @@
+main=undefined
+-- | aksdjhaskdjhasdsakjhdajksda
diff --git a/testsuite/tests/haddock/should_fail_flag_haddock/haddockE001.stderr b/testsuite/tests/haddock/should_fail_flag_haddock/haddockE001.stderr
new file mode 100644
index 0000000000..f1332ea124
--- /dev/null
+++ b/testsuite/tests/haddock/should_fail_flag_haddock/haddockE001.stderr
@@ -0,0 +1,2 @@
+
+haddockE001.hs:3:0: parse error (possibly incorrect indentation)
diff --git a/testsuite/tests/haddock/should_fail_flag_haddock/haddockE002.hs b/testsuite/tests/haddock/should_fail_flag_haddock/haddockE002.hs
new file mode 100644
index 0000000000..7c49f02e5a
--- /dev/null
+++ b/testsuite/tests/haddock/should_fail_flag_haddock/haddockE002.hs
@@ -0,0 +1,6 @@
+
+module ShouldFail where
+
+-- | aksdjhaskdjhasdsakjhdajksd
+
+main=undefined
diff --git a/testsuite/tests/haddock/should_fail_flag_haddock/haddockE002.stderr b/testsuite/tests/haddock/should_fail_flag_haddock/haddockE002.stderr
new file mode 100644
index 0000000000..cb1e257b3d
--- /dev/null
+++ b/testsuite/tests/haddock/should_fail_flag_haddock/haddockE002.stderr
@@ -0,0 +1,2 @@
+
+haddockE002.hs:6:0: parse error (possibly incorrect indentation)
diff --git a/testsuite/tests/haddock/should_fail_flag_haddock/haddockE003.hs b/testsuite/tests/haddock/should_fail_flag_haddock/haddockE003.hs
new file mode 100644
index 0000000000..ee6aef2bf8
--- /dev/null
+++ b/testsuite/tests/haddock/should_fail_flag_haddock/haddockE003.hs
@@ -0,0 +1,9 @@
+
+module ShouldFail where
+
+-- aslkdjasldkjasldkaj
+-- | awlkdajsads
+-- asdasödlklas
+---qww
+-----------------
+main=undefined
diff --git a/testsuite/tests/haddock/should_fail_flag_haddock/haddockE003.stderr b/testsuite/tests/haddock/should_fail_flag_haddock/haddockE003.stderr
new file mode 100644
index 0000000000..6965356fad
--- /dev/null
+++ b/testsuite/tests/haddock/should_fail_flag_haddock/haddockE003.stderr
@@ -0,0 +1,2 @@
+
+haddockE003.hs:9:0: parse error (possibly incorrect indentation)
diff --git a/testsuite/tests/haddock/should_fail_flag_haddock/haddockE004.hs b/testsuite/tests/haddock/should_fail_flag_haddock/haddockE004.hs
new file mode 100644
index 0000000000..d73fe8f796
--- /dev/null
+++ b/testsuite/tests/haddock/should_fail_flag_haddock/haddockE004.hs
@@ -0,0 +1,3 @@
+
+-- | awlkdajsads
+main=undefined
diff --git a/testsuite/tests/haddock/should_fail_flag_haddock/haddockE004.stderr b/testsuite/tests/haddock/should_fail_flag_haddock/haddockE004.stderr
new file mode 100644
index 0000000000..3462c61a8c
--- /dev/null
+++ b/testsuite/tests/haddock/should_fail_flag_haddock/haddockE004.stderr
@@ -0,0 +1,2 @@
+
+haddockE004.hs:3:1: parse error on input `main'