@@ -17,6 +17,7 @@ import Data.Foldable
1717import Data.List
1818import Development.IDE.GHC.Util
1919import qualified Data.Text as T
20+import Development.IDE.Spans.Common
2021import Development.IDE.Test
2122import Development.IDE.Test.Runfiles
2223import Development.IDE.Types.Location
@@ -53,6 +54,7 @@ main = defaultMain $ testGroup "HIE"
5354 , preprocessorTests
5455 , thTests
5556 , unitTests
57+ , haddockTests
5658 ]
5759
5860initializeResponseTests :: TestTree
@@ -1638,6 +1640,66 @@ data Expect
16381640
16391641mkR :: Int -> Int -> Int -> Int -> Expect
16401642mkR startLine startColumn endLine endColumn = ExpectRange $ mkRange startLine startColumn endLine endColumn
1643+
1644+haddockTests :: TestTree
1645+haddockTests
1646+ = testGroup "haddock"
1647+ [ testCase "Num" $ checkHaddock
1648+ (unlines
1649+ [ "However, '(+)' and '(*)' are"
1650+ , "customarily expected to define a ring and have the following properties:"
1651+ , ""
1652+ , "[__Associativity of (+)__]: @(x + y) + z@ = @x + (y + z)@"
1653+ , "[__Commutativity of (+)__]: @x + y@ = @y + x@"
1654+ , "[__@fromInteger 0@ is the additive identity__]: @x + fromInteger 0@ = @x@"
1655+ ]
1656+ )
1657+ (unlines
1658+ [ ""
1659+ , ""
1660+#if MIN_VERSION_haddock_library(1,8,0)
1661+ , "However, `(+)` and `(*)` are"
1662+#else
1663+ , "However, '(+)' and '(*)' are"
1664+#endif
1665+ , "customarily expected to define a ring and have the following properties: "
1666+ , "+ ****Associativity of (+)****: `(x + y) + z` = `x + (y + z)`"
1667+ , "+ ****Commutativity of (+)****: `x + y` = `y + x`"
1668+ , "+ ****`fromInteger 0` is the additive identity****: `x + fromInteger 0` = `x`"
1669+ ]
1670+ )
1671+ , testCase "unsafePerformIO" $ checkHaddock
1672+ (unlines
1673+ [ "may require"
1674+ , "different precautions:"
1675+ , ""
1676+ , " * Use @{\\-\\# NOINLINE foo \\#-\\}@ as a pragma on any function @foo@"
1677+ , " that calls 'unsafePerformIO'. If the call is inlined,"
1678+ , " the I\\/O may be performed more than once."
1679+ , ""
1680+ , " * Use the compiler flag @-fno-cse@ to prevent common sub-expression"
1681+ , " elimination being performed on the module."
1682+ , ""
1683+ ]
1684+ )
1685+ (unlines
1686+ [ ""
1687+ , ""
1688+ , "may require"
1689+ , "different precautions: "
1690+ , "+ Use `{-# NOINLINE foo #-}` as a pragma on any function `foo` "
1691+ , " that calls `unsafePerformIO` . If the call is inlined,"
1692+ , " the I/O may be performed more than once."
1693+ , ""
1694+ , "+ Use the compiler flag `-fno-cse` to prevent common sub-expression"
1695+ , " elimination being performed on the module."
1696+ , ""
1697+ ]
1698+ )
1699+ ]
1700+ where
1701+ checkHaddock s txt = spanDocToMarkdownForTest s @?= txt
1702+
16411703----------------------------------------------------------------------
16421704-- Utils
16431705