From a7cfb1d83c7e0f97a806e1f2c202416e625b2ce2 Mon Sep 17 00:00:00 2001 From: David Waern Date: Tue, 11 May 2010 19:14:31 +0000 Subject: Re-organise the testsuite structure --- tests/README | 28 - tests/copy.hs | 30 - tests/golden-tests/README | 28 + tests/golden-tests/copy.hs | 30 + tests/golden-tests/runtests.hs | 114 + tests/golden-tests/tests/A.hs | 2 + tests/golden-tests/tests/A.html.ref | 119 + tests/golden-tests/tests/B.hs | 2 + tests/golden-tests/tests/B.html.ref | 84 + tests/golden-tests/tests/Bug1.hs | 6 + tests/golden-tests/tests/Bug1.html.ref | 150 + tests/golden-tests/tests/Bug2.hs | 4 + tests/golden-tests/tests/Bug2.html.ref | 90 + tests/golden-tests/tests/Bug3.hs | 6 + tests/golden-tests/tests/Bug3.html.ref | 116 + tests/golden-tests/tests/Bug4.hs | 5 + tests/golden-tests/tests/Bug4.html.ref | 115 + tests/golden-tests/tests/Bug6.hs | 23 + tests/golden-tests/tests/Bug6.html.ref | 482 +++ tests/golden-tests/tests/Bug7.hs | 12 + tests/golden-tests/tests/Bug7.html.ref | 244 ++ tests/golden-tests/tests/Bug8.hs | 17 + tests/golden-tests/tests/Bug8.html.ref | 135 + tests/golden-tests/tests/Bugs.hs | 3 + tests/golden-tests/tests/Bugs.html.ref | 120 + tests/golden-tests/tests/CrossPackageDocs.hs | 3 + tests/golden-tests/tests/CrossPackageDocs.html.ref | 525 ++++ tests/golden-tests/tests/Examples.hs | 34 + tests/golden-tests/tests/Examples.html.ref | 208 ++ tests/golden-tests/tests/FunArgs.hs | 16 + tests/golden-tests/tests/FunArgs.html.ref | 190 ++ tests/golden-tests/tests/GADTRecords.hs | 12 + tests/golden-tests/tests/GADTRecords.html.ref | 288 ++ tests/golden-tests/tests/Hash.hs | 51 + tests/golden-tests/tests/Hash.html.ref | 476 +++ tests/golden-tests/tests/Hidden.hs | 6 + tests/golden-tests/tests/NamedDoc.hs | 4 + tests/golden-tests/tests/NamedDoc.html.ref | 98 + tests/golden-tests/tests/NoLayout.hs | 12 + tests/golden-tests/tests/NoLayout.html.ref | 115 + tests/golden-tests/tests/NonGreedy.hs | 5 + tests/golden-tests/tests/NonGreedy.html.ref | 115 + tests/golden-tests/tests/QuasiExpr.hs | 36 + tests/golden-tests/tests/QuasiExpr.html.ref | 346 +++ tests/golden-tests/tests/QuasiQuote.hs | 9 + tests/golden-tests/tests/QuasiQuote.html.ref | 90 + tests/golden-tests/tests/TH.hs | 8 + tests/golden-tests/tests/TH.html.ref | 89 + tests/golden-tests/tests/TH2.hs | 8 + tests/golden-tests/tests/TH2.html.ref | 71 + tests/golden-tests/tests/Test.hs | 410 +++ tests/golden-tests/tests/Test.html.ref | 3110 ++++++++++++++++++++ tests/golden-tests/tests/Ticket112.hs | 9 + tests/golden-tests/tests/Ticket112.html.ref | 116 + tests/golden-tests/tests/Ticket61.hs | 3 + tests/golden-tests/tests/Ticket61.html.ref | 128 + tests/golden-tests/tests/Ticket61_Hidden.hs | 7 + tests/golden-tests/tests/Ticket75.hs | 7 + tests/golden-tests/tests/Ticket75.html.ref | 174 ++ tests/golden-tests/tests/TypeFamilies.hs | 28 + tests/golden-tests/tests/TypeFamilies.html.ref | 316 ++ tests/golden-tests/tests/TypeOperators.hs | 22 + tests/golden-tests/tests/TypeOperators.html.ref | 388 +++ tests/golden-tests/tests/Visible.hs | 3 + tests/golden-tests/tests/Visible.html.ref | 91 + tests/parsetests.hs | 56 - tests/runparsetests.sh | 14 - tests/runtests.hs | 114 - tests/tests/A.hs | 2 - tests/tests/A.html.ref | 119 - tests/tests/B.hs | 2 - tests/tests/B.html.ref | 84 - tests/tests/Bug1.hs | 6 - tests/tests/Bug1.html.ref | 150 - tests/tests/Bug2.hs | 4 - tests/tests/Bug2.html.ref | 90 - tests/tests/Bug3.hs | 6 - tests/tests/Bug3.html.ref | 116 - tests/tests/Bug4.hs | 5 - tests/tests/Bug4.html.ref | 115 - tests/tests/Bug6.hs | 23 - tests/tests/Bug6.html.ref | 482 --- tests/tests/Bug7.hs | 12 - tests/tests/Bug7.html.ref | 244 -- tests/tests/Bug8.hs | 17 - tests/tests/Bug8.html.ref | 135 - tests/tests/Bugs.hs | 3 - tests/tests/Bugs.html.ref | 120 - tests/tests/CrossPackageDocs.hs | 3 - tests/tests/CrossPackageDocs.html.ref | 525 ---- tests/tests/Examples.hs | 34 - tests/tests/Examples.html.ref | 208 -- tests/tests/FunArgs.hs | 16 - tests/tests/FunArgs.html.ref | 190 -- tests/tests/GADTRecords.hs | 12 - tests/tests/GADTRecords.html.ref | 288 -- tests/tests/Hash.hs | 51 - tests/tests/Hash.html.ref | 476 --- tests/tests/Hidden.hs | 6 - tests/tests/NamedDoc.hs | 4 - tests/tests/NamedDoc.html.ref | 98 - tests/tests/NoLayout.hs | 12 - tests/tests/NoLayout.html.ref | 115 - tests/tests/NonGreedy.hs | 5 - tests/tests/NonGreedy.html.ref | 115 - tests/tests/QuasiExpr.hs | 36 - tests/tests/QuasiExpr.html.ref | 346 --- tests/tests/QuasiQuote.hs | 9 - tests/tests/QuasiQuote.html.ref | 90 - tests/tests/TH.hs | 8 - tests/tests/TH.html.ref | 89 - tests/tests/TH2.hs | 8 - tests/tests/TH2.html.ref | 71 - tests/tests/Test.hs | 410 --- tests/tests/Test.html.ref | 3110 -------------------- tests/tests/Ticket112.hs | 9 - tests/tests/Ticket112.html.ref | 116 - tests/tests/Ticket61.hs | 3 - tests/tests/Ticket61.html.ref | 128 - tests/tests/Ticket61_Hidden.hs | 7 - tests/tests/Ticket75.hs | 7 - tests/tests/Ticket75.html.ref | 174 -- tests/tests/TypeFamilies.hs | 28 - tests/tests/TypeFamilies.html.ref | 316 -- tests/tests/TypeOperators.hs | 22 - tests/tests/TypeOperators.html.ref | 388 --- tests/tests/Visible.hs | 3 - tests/tests/Visible.html.ref | 91 - tests/unit-tests/parsetests.hs | 56 + tests/unit-tests/runparsetests.sh | 14 + 130 files changed, 9604 insertions(+), 9604 deletions(-) delete mode 100644 tests/README delete mode 100644 tests/copy.hs create mode 100644 tests/golden-tests/README create mode 100644 tests/golden-tests/copy.hs create mode 100644 tests/golden-tests/runtests.hs create mode 100644 tests/golden-tests/tests/A.hs create mode 100644 tests/golden-tests/tests/A.html.ref create mode 100644 tests/golden-tests/tests/B.hs create mode 100644 tests/golden-tests/tests/B.html.ref create mode 100644 tests/golden-tests/tests/Bug1.hs create mode 100644 tests/golden-tests/tests/Bug1.html.ref create mode 100644 tests/golden-tests/tests/Bug2.hs create mode 100644 tests/golden-tests/tests/Bug2.html.ref create mode 100644 tests/golden-tests/tests/Bug3.hs create mode 100644 tests/golden-tests/tests/Bug3.html.ref create mode 100644 tests/golden-tests/tests/Bug4.hs create mode 100644 tests/golden-tests/tests/Bug4.html.ref create mode 100644 tests/golden-tests/tests/Bug6.hs create mode 100644 tests/golden-tests/tests/Bug6.html.ref create mode 100644 tests/golden-tests/tests/Bug7.hs create mode 100644 tests/golden-tests/tests/Bug7.html.ref create mode 100644 tests/golden-tests/tests/Bug8.hs create mode 100644 tests/golden-tests/tests/Bug8.html.ref create mode 100644 tests/golden-tests/tests/Bugs.hs create mode 100644 tests/golden-tests/tests/Bugs.html.ref create mode 100644 tests/golden-tests/tests/CrossPackageDocs.hs create mode 100644 tests/golden-tests/tests/CrossPackageDocs.html.ref create mode 100644 tests/golden-tests/tests/Examples.hs create mode 100644 tests/golden-tests/tests/Examples.html.ref create mode 100644 tests/golden-tests/tests/FunArgs.hs create mode 100644 tests/golden-tests/tests/FunArgs.html.ref create mode 100644 tests/golden-tests/tests/GADTRecords.hs create mode 100644 tests/golden-tests/tests/GADTRecords.html.ref create mode 100644 tests/golden-tests/tests/Hash.hs create mode 100644 tests/golden-tests/tests/Hash.html.ref create mode 100644 tests/golden-tests/tests/Hidden.hs create mode 100644 tests/golden-tests/tests/NamedDoc.hs create mode 100644 tests/golden-tests/tests/NamedDoc.html.ref create mode 100644 tests/golden-tests/tests/NoLayout.hs create mode 100644 tests/golden-tests/tests/NoLayout.html.ref create mode 100644 tests/golden-tests/tests/NonGreedy.hs create mode 100644 tests/golden-tests/tests/NonGreedy.html.ref create mode 100644 tests/golden-tests/tests/QuasiExpr.hs create mode 100644 tests/golden-tests/tests/QuasiExpr.html.ref create mode 100644 tests/golden-tests/tests/QuasiQuote.hs create mode 100644 tests/golden-tests/tests/QuasiQuote.html.ref create mode 100644 tests/golden-tests/tests/TH.hs create mode 100644 tests/golden-tests/tests/TH.html.ref create mode 100644 tests/golden-tests/tests/TH2.hs create mode 100644 tests/golden-tests/tests/TH2.html.ref create mode 100644 tests/golden-tests/tests/Test.hs create mode 100644 tests/golden-tests/tests/Test.html.ref create mode 100644 tests/golden-tests/tests/Ticket112.hs create mode 100644 tests/golden-tests/tests/Ticket112.html.ref create mode 100644 tests/golden-tests/tests/Ticket61.hs create mode 100644 tests/golden-tests/tests/Ticket61.html.ref create mode 100644 tests/golden-tests/tests/Ticket61_Hidden.hs create mode 100644 tests/golden-tests/tests/Ticket75.hs create mode 100644 tests/golden-tests/tests/Ticket75.html.ref create mode 100644 tests/golden-tests/tests/TypeFamilies.hs create mode 100644 tests/golden-tests/tests/TypeFamilies.html.ref create mode 100644 tests/golden-tests/tests/TypeOperators.hs create mode 100644 tests/golden-tests/tests/TypeOperators.html.ref create mode 100644 tests/golden-tests/tests/Visible.hs create mode 100644 tests/golden-tests/tests/Visible.html.ref delete mode 100644 tests/parsetests.hs delete mode 100644 tests/runparsetests.sh delete mode 100644 tests/runtests.hs delete mode 100644 tests/tests/A.hs delete mode 100644 tests/tests/A.html.ref delete mode 100644 tests/tests/B.hs delete mode 100644 tests/tests/B.html.ref delete mode 100644 tests/tests/Bug1.hs delete mode 100644 tests/tests/Bug1.html.ref delete mode 100644 tests/tests/Bug2.hs delete mode 100644 tests/tests/Bug2.html.ref delete mode 100644 tests/tests/Bug3.hs delete mode 100644 tests/tests/Bug3.html.ref delete mode 100644 tests/tests/Bug4.hs delete mode 100644 tests/tests/Bug4.html.ref delete mode 100644 tests/tests/Bug6.hs delete mode 100644 tests/tests/Bug6.html.ref delete mode 100644 tests/tests/Bug7.hs delete mode 100644 tests/tests/Bug7.html.ref delete mode 100644 tests/tests/Bug8.hs delete mode 100644 tests/tests/Bug8.html.ref delete mode 100644 tests/tests/Bugs.hs delete mode 100644 tests/tests/Bugs.html.ref delete mode 100644 tests/tests/CrossPackageDocs.hs delete mode 100644 tests/tests/CrossPackageDocs.html.ref delete mode 100644 tests/tests/Examples.hs delete mode 100644 tests/tests/Examples.html.ref delete mode 100644 tests/tests/FunArgs.hs delete mode 100644 tests/tests/FunArgs.html.ref delete mode 100644 tests/tests/GADTRecords.hs delete mode 100644 tests/tests/GADTRecords.html.ref delete mode 100644 tests/tests/Hash.hs delete mode 100644 tests/tests/Hash.html.ref delete mode 100644 tests/tests/Hidden.hs delete mode 100644 tests/tests/NamedDoc.hs delete mode 100644 tests/tests/NamedDoc.html.ref delete mode 100644 tests/tests/NoLayout.hs delete mode 100644 tests/tests/NoLayout.html.ref delete mode 100644 tests/tests/NonGreedy.hs delete mode 100644 tests/tests/NonGreedy.html.ref delete mode 100644 tests/tests/QuasiExpr.hs delete mode 100644 tests/tests/QuasiExpr.html.ref delete mode 100644 tests/tests/QuasiQuote.hs delete mode 100644 tests/tests/QuasiQuote.html.ref delete mode 100644 tests/tests/TH.hs delete mode 100644 tests/tests/TH.html.ref delete mode 100644 tests/tests/TH2.hs delete mode 100644 tests/tests/TH2.html.ref delete mode 100644 tests/tests/Test.hs delete mode 100644 tests/tests/Test.html.ref delete mode 100644 tests/tests/Ticket112.hs delete mode 100644 tests/tests/Ticket112.html.ref delete mode 100644 tests/tests/Ticket61.hs delete mode 100644 tests/tests/Ticket61.html.ref delete mode 100644 tests/tests/Ticket61_Hidden.hs delete mode 100644 tests/tests/Ticket75.hs delete mode 100644 tests/tests/Ticket75.html.ref delete mode 100644 tests/tests/TypeFamilies.hs delete mode 100644 tests/tests/TypeFamilies.html.ref delete mode 100644 tests/tests/TypeOperators.hs delete mode 100644 tests/tests/TypeOperators.html.ref delete mode 100644 tests/tests/Visible.hs delete mode 100644 tests/tests/Visible.html.ref create mode 100644 tests/unit-tests/parsetests.hs create mode 100644 tests/unit-tests/runparsetests.sh diff --git a/tests/README b/tests/README deleted file mode 100644 index 5c5bef60..00000000 --- a/tests/README +++ /dev/null @@ -1,28 +0,0 @@ - -A testsuite for Haddock that uses the concept of "golden files" (compares -output files against a set of reference files). - -To add a new test: - - 1) Create a module in the "tests" directory. - - 2) Run runtests.hs. You should now have output/.html. The test - passes since there is no reference file to compare with. - - 3) To make a reference file from the output file, do - runhaskell copy.hs - -Tips and tricks: - -You can - runhaskell copy.hs - -to copy all output files into reference files. - -You can - runhaskell runtests.hs all - -to continue despite a failing test. - -You can pass extra options to haddock like so - runhaskell runtests.hs --xhtml all diff --git a/tests/copy.hs b/tests/copy.hs deleted file mode 100644 index fa18fe9c..00000000 --- a/tests/copy.hs +++ /dev/null @@ -1,30 +0,0 @@ -import System.Cmd -import System.Environment -import System.FilePath -import System.Exit -import System.Directory -import Data.List -import Control.Monad -import Text.Regex - - -main = do - args <- getArgs - dir <- getCurrentDirectory - contents <- getDirectoryContents (dir "output") - if not $ null args - then - mapM copy [ "output" file | file <- contents, ".html" `isSuffixOf` file, takeBaseName file `elem` args ] - else - mapM copy [ "output" file | file <- contents, ".html" `isSuffixOf` file ] - - -copy file = do - let new = "tests" takeFileName file <.> ".ref" - print file - print new - contents <- readFile file - writeFile new (stripLinks contents) - - -stripLinks f = subRegex (mkRegexWithOpts "]*>" False False) f "" diff --git a/tests/golden-tests/README b/tests/golden-tests/README new file mode 100644 index 00000000..f538cea7 --- /dev/null +++ b/tests/golden-tests/README @@ -0,0 +1,28 @@ + +This is a testsuite for Haddock that uses the concept of "golden files". That +is, it compares output files against a set of reference files. + +To add a new test: + + 1) Create a module in the "tests" directory. + + 2) Run runtests.hs. You should now have output/.html. The test + passes since there is no reference file to compare with. + + 3) To make a reference file from the output file, do + runhaskell copy.hs + +Tips and tricks: + +You can + runhaskell copy.hs + +to copy all output files into reference files. + +You can + runhaskell runtests.hs all + +to continue despite a failing test. + +You can pass extra options to haddock like so + runhaskell runtests.hs --xhtml all diff --git a/tests/golden-tests/copy.hs b/tests/golden-tests/copy.hs new file mode 100644 index 00000000..fa18fe9c --- /dev/null +++ b/tests/golden-tests/copy.hs @@ -0,0 +1,30 @@ +import System.Cmd +import System.Environment +import System.FilePath +import System.Exit +import System.Directory +import Data.List +import Control.Monad +import Text.Regex + + +main = do + args <- getArgs + dir <- getCurrentDirectory + contents <- getDirectoryContents (dir "output") + if not $ null args + then + mapM copy [ "output" file | file <- contents, ".html" `isSuffixOf` file, takeBaseName file `elem` args ] + else + mapM copy [ "output" file | file <- contents, ".html" `isSuffixOf` file ] + + +copy file = do + let new = "tests" takeFileName file <.> ".ref" + print file + print new + contents <- readFile file + writeFile new (stripLinks contents) + + +stripLinks f = subRegex (mkRegexWithOpts "]*>" False False) f "" diff --git a/tests/golden-tests/runtests.hs b/tests/golden-tests/runtests.hs new file mode 100644 index 00000000..99a47828 --- /dev/null +++ b/tests/golden-tests/runtests.hs @@ -0,0 +1,114 @@ +import System.Cmd +import System.Environment +import System.FilePath +import System.Exit +import System.Directory +import System.Process +import Data.List +import Control.Monad +import Text.Printf +import Text.Regex +import Distribution.Simple.Utils +import Distribution.Simple.Program +import Distribution.Verbosity +import Data.Maybe + + +haddockPath = ".." "dist" "build" "haddock" "haddock" + + +main = do + test + putStrLn "All tests passed!" + + +test = do + x <- doesFileExist haddockPath + when (not x) $ die "you need to run 'cabal build' successfully first" + + contents <- getDirectoryContents "tests" + args <- getArgs + let (opts, spec) = span ("-" `isPrefixOf`) args + let mods = + case spec of + x:_ | x /= "all" -> [x ++ ".hs"] + _ -> filter ((==) ".hs" . takeExtension) contents + + let outdir = "output" + let mods' = map ("tests" ) mods + putStrLn "" + putStrLn "Haddock version: " + h1 <- runProcess haddockPath ["--version"] Nothing + (Just [("haddock_datadir", "../.")]) Nothing Nothing Nothing + waitForProcess h1 + putStrLn "" + putStrLn "GHC version: " + h2 <- runProcess haddockPath ["--ghc-version"] Nothing + (Just [("haddock_datadir", "../.")]) Nothing Nothing Nothing + waitForProcess h2 + putStrLn "" + + -- TODO: use Distribution.* to get the packages instead + libdir <- rawSystemStdout normal haddockPath ["--print-ghc-libdir"] + let librariesPath = "..""..""share""doc""ghc""html""libraries" + + let mkDep name version = + let path = init libdir librariesPath name ++ "-" ++ version + in "-i " ++ path ++ "," ++ path name ++ ".haddock" + + let base = mkDep "base" "4.2.0.0" + process = mkDep "process" "1.0.1.2" + ghcprim = mkDep "ghc-prim" "0.2.0.0" + + putStrLn "Running tests..." + handle <- runProcess haddockPath + (["-w", "-o", outdir, "-h", "--optghc=-fglasgow-exts" + , "--optghc=-w", base, process, ghcprim] ++ opts ++ mods') + Nothing (Just [("haddock_datadir", "../.")]) Nothing + Nothing Nothing + + code <- waitForProcess handle + when (code /= ExitSuccess) $ error "Haddock run failed! Exiting." + check mods (if not (null args) && args !! 0 == "all" then False else True) + + +check modules strict = do + forM_ modules $ \mod -> do + let outfile = "output" (dropExtension mod ++ ".html") + let reffile = "tests" dropExtension mod ++ ".html.ref" + b <- doesFileExist reffile + if b + then do + copyFile reffile ("output" takeFileName reffile) + out <- readFile outfile + ref <- readFile reffile + if not $ haddockEq out ref + then do + putStrLn $ "Output for " ++ mod ++ " has changed! Exiting with diff:" + let ref' = stripLinks ref + out' = stripLinks out + let reffile' = "output" takeFileName reffile ++ ".nolinks" + outfile' = "output" takeFileName outfile ++ ".nolinks" + writeFile reffile' ref' + writeFile outfile' out' + b <- programOnPath "colordiff" + if b + then system $ "colordiff " ++ reffile' ++ " " ++ outfile' + else system $ "diff " ++ reffile' ++ " " ++ outfile' + if strict then exitFailure else return () + else do + putStrLn $ "Pass: " ++ mod + else do + putStrLn $ "Pass: " ++ mod ++ " (no .ref file)" + + +haddockEq file1 file2 = stripLinks file1 == stripLinks file2 + + +stripLinks f = subRegex (mkRegexWithOpts "]*>" False False) f "" + + +programOnPath p = do + result <- findProgramLocation silent p + return (isJust result) + diff --git a/tests/golden-tests/tests/A.hs b/tests/golden-tests/tests/A.hs new file mode 100644 index 00000000..4a344a24 --- /dev/null +++ b/tests/golden-tests/tests/A.hs @@ -0,0 +1,2 @@ +module A where +data A = A diff --git a/tests/golden-tests/tests/A.html.ref b/tests/golden-tests/tests/A.html.ref new file mode 100644 index 00000000..69567351 --- /dev/null +++ b/tests/golden-tests/tests/A.html.ref @@ -0,0 +1,119 @@ + + +A
 ContentsIndex
A
Documentation
data A
Constructors
A
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/B.hs b/tests/golden-tests/tests/B.hs new file mode 100644 index 00000000..3a31507e --- /dev/null +++ b/tests/golden-tests/tests/B.hs @@ -0,0 +1,2 @@ +module B ( module A ) where +import A diff --git a/tests/golden-tests/tests/B.html.ref b/tests/golden-tests/tests/B.html.ref new file mode 100644 index 00000000..007d084b --- /dev/null +++ b/tests/golden-tests/tests/B.html.ref @@ -0,0 +1,84 @@ + + +B
 ContentsIndex
B
Documentation
module A
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/Bug1.hs b/tests/golden-tests/tests/Bug1.hs new file mode 100644 index 00000000..af1ed4d3 --- /dev/null +++ b/tests/golden-tests/tests/Bug1.hs @@ -0,0 +1,6 @@ +module Bug1 where + +-- | We should have different anchors for constructors and types\/classes. This +-- hyperlink should point to the type constructor by default: 'T'. +data T = T + diff --git a/tests/golden-tests/tests/Bug1.html.ref b/tests/golden-tests/tests/Bug1.html.ref new file mode 100644 index 00000000..861b7ee7 --- /dev/null +++ b/tests/golden-tests/tests/Bug1.html.ref @@ -0,0 +1,150 @@ + + +Bug1
 ContentsIndex
Bug1
Synopsis
data T = T
Documentation
data T
We should have different anchors for constructors and types/classes. This + hyperlink should point to the type constructor by default: T. +
Constructors
T
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/Bug2.hs b/tests/golden-tests/tests/Bug2.hs new file mode 100644 index 00000000..9121922e --- /dev/null +++ b/tests/golden-tests/tests/Bug2.hs @@ -0,0 +1,4 @@ +module Bug2 ( x ) where +import B +x :: A +x = A diff --git a/tests/golden-tests/tests/Bug2.html.ref b/tests/golden-tests/tests/Bug2.html.ref new file mode 100644 index 00000000..e344bd69 --- /dev/null +++ b/tests/golden-tests/tests/Bug2.html.ref @@ -0,0 +1,90 @@ + + +Bug2
 ContentsIndex
Bug2
Documentation
x :: A
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/Bug3.hs b/tests/golden-tests/tests/Bug3.hs new file mode 100644 index 00000000..67e57892 --- /dev/null +++ b/tests/golden-tests/tests/Bug3.hs @@ -0,0 +1,6 @@ +module Bug3 where + +-- | /multi-line +-- emphasis/ +foo :: Int +foo = undefined diff --git a/tests/golden-tests/tests/Bug3.html.ref b/tests/golden-tests/tests/Bug3.html.ref new file mode 100644 index 00000000..dc24ddd0 --- /dev/null +++ b/tests/golden-tests/tests/Bug3.html.ref @@ -0,0 +1,116 @@ + + +Bug3
 ContentsIndex
Bug3
Synopsis
foo :: Int
Documentation
foo :: Int
/multi-line + emphasis/ +
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/Bug4.hs b/tests/golden-tests/tests/Bug4.hs new file mode 100644 index 00000000..425a77aa --- /dev/null +++ b/tests/golden-tests/tests/Bug4.hs @@ -0,0 +1,5 @@ +module Bug4 where +-- | don't use apostrophe's in the wrong place's +foo :: Int +foo = undefined + diff --git a/tests/golden-tests/tests/Bug4.html.ref b/tests/golden-tests/tests/Bug4.html.ref new file mode 100644 index 00000000..1a09fff3 --- /dev/null +++ b/tests/golden-tests/tests/Bug4.html.ref @@ -0,0 +1,115 @@ + + +Bug4
 ContentsIndex
Bug4
Synopsis
foo :: Int
Documentation
foo :: Int
don't use apostrophe's in the wrong place's +
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/Bug6.hs b/tests/golden-tests/tests/Bug6.hs new file mode 100644 index 00000000..17411f31 --- /dev/null +++ b/tests/golden-tests/tests/Bug6.hs @@ -0,0 +1,23 @@ +-- | Exporting records. +module Bug6( A(A), B(B), b, C(C,c1,c2), D(D,d1), E(E) ) where + +-- | +-- This record is exported without its field +data A = A { a :: Int } + +-- | +-- .. with its field, but the field is named separately in the export list +-- (the field isn't documented separately since it is already documented here) +data B = B { b :: Int } + +-- | +-- .. with fields names as subordinate names in the export +data C = C { c1 :: Int, c2 :: Int } + +-- | +-- .. with only some of the fields exported (we can't handle this one - +-- how do we render the declaration?) +data D = D { d1 :: Int, d2 :: Int } + +-- | a newtype with a field +newtype E = E { e :: Int } diff --git a/tests/golden-tests/tests/Bug6.html.ref b/tests/golden-tests/tests/Bug6.html.ref new file mode 100644 index 00000000..3686fd6d --- /dev/null +++ b/tests/golden-tests/tests/Bug6.html.ref @@ -0,0 +1,482 @@ + + +Bug6
 ContentsIndex
Bug6
Description
Exporting records. +
Synopsis
data A = A Int
data B = B {
b :: Int
}
data C = C {
c1 :: Int
c2 :: Int
}
data D = D Int Int
newtype E = E Int
Documentation
data A
This record is exported without its field +
Constructors
A Int
data B
.. with its field, but the field is named separately in the export list + (the field isn't documented separately since it is already documented here) +
Constructors
B
b :: Int
data C
.. with fields names as subordinate names in the export +
Constructors
C
c1 :: Int
c2 :: Int
data D
.. with only some of the fields exported (we can't handle this one - + how do we render the declaration?) +
Constructors
D Int Int
newtype E
a newtype with a field +
Constructors
E Int
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/Bug7.hs b/tests/golden-tests/tests/Bug7.hs new file mode 100644 index 00000000..8cf57914 --- /dev/null +++ b/tests/golden-tests/tests/Bug7.hs @@ -0,0 +1,12 @@ +-- | This module caused a duplicate instance in the documentation for the Foo +-- type. +module Bug7 where + +-- | The Foo datatype +data Foo = Foo + +-- | The Bar class +class Bar x y + +-- | Just one instance +instance Bar Foo Foo diff --git a/tests/golden-tests/tests/Bug7.html.ref b/tests/golden-tests/tests/Bug7.html.ref new file mode 100644 index 00000000..83ce5323 --- /dev/null +++ b/tests/golden-tests/tests/Bug7.html.ref @@ -0,0 +1,244 @@ + + +Bug7
 ContentsIndex
Bug7
Description
This module caused a duplicate instance in the documentation for the Foo + type. +
Synopsis
data Foo = Foo
class Bar x y
Documentation
data Foo
The Foo datatype +
Constructors
Foo
show/hide Instances
Bar Foo FooJust one instance +
class Bar x y
The Bar class +
show/hide Instances
Bar Foo FooJust one instance +
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/Bug8.hs b/tests/golden-tests/tests/Bug8.hs new file mode 100644 index 00000000..0f279c29 --- /dev/null +++ b/tests/golden-tests/tests/Bug8.hs @@ -0,0 +1,17 @@ +{- Note that declarations without type signatures are not included in the + documentation. They could be, but that's a missing feature. -} + +module Bug8 where + +infix --> +infix ---> + +data Typ = Type (String,[Typ]) + | TFree (String, [String]) + +x --> y = Type("fun",[s,t]) +(--->) = flip $ foldr (-->) + +s = undefined +t = undefined +main = undefined diff --git a/tests/golden-tests/tests/Bug8.html.ref b/tests/golden-tests/tests/Bug8.html.ref new file mode 100644 index 00000000..907602b7 --- /dev/null +++ b/tests/golden-tests/tests/Bug8.html.ref @@ -0,0 +1,135 @@ + + +Bug8
 ContentsIndex
Bug8
Documentation
data Typ
Constructors
Type (String, [Typ])
TFree (String, [String])
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/Bugs.hs b/tests/golden-tests/tests/Bugs.hs new file mode 100644 index 00000000..8e1f0079 --- /dev/null +++ b/tests/golden-tests/tests/Bugs.hs @@ -0,0 +1,3 @@ +module Bugs where + +data A a = A a (a -> Int) diff --git a/tests/golden-tests/tests/Bugs.html.ref b/tests/golden-tests/tests/Bugs.html.ref new file mode 100644 index 00000000..75666af0 --- /dev/null +++ b/tests/golden-tests/tests/Bugs.html.ref @@ -0,0 +1,120 @@ + + +Bugs
 ContentsIndex
Bugs
Documentation
data A a
Constructors
A a (a -> Int)
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/CrossPackageDocs.hs b/tests/golden-tests/tests/CrossPackageDocs.hs new file mode 100644 index 00000000..de55060e --- /dev/null +++ b/tests/golden-tests/tests/CrossPackageDocs.hs @@ -0,0 +1,3 @@ +module CrossPackageDocs (map, Monad(..), runInteractiveProcess) where + +import System.Process diff --git a/tests/golden-tests/tests/CrossPackageDocs.html.ref b/tests/golden-tests/tests/CrossPackageDocs.html.ref new file mode 100644 index 00000000..375984dc --- /dev/null +++ b/tests/golden-tests/tests/CrossPackageDocs.html.ref @@ -0,0 +1,525 @@ + + +CrossPackageDocs
 ContentsIndex
CrossPackageDocs
Synopsis
map :: (a -> b) -> [a] -> [b]
class Monad m where
(>>=) :: m a -> (a -> m b) -> m b
(>>) :: m a -> m b -> m b
return :: a -> m a
fail :: String -> m a
runInteractiveProcess :: FilePath -> [String] -> Maybe FilePath -> Maybe [(String, String)] -> IO (Handle, Handle, Handle, ProcessHandle)
Documentation
map :: (a -> b) -> [a] -> [b]

map f xs is the list obtained by applying f to each element + of xs, i.e., +

map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn] + map f [x1, x2, ...] == [f x1, f x2, ...] +
class Monad m where

The Monad class defines the basic operations over a monad, +a concept from a branch of mathematics known as category theory. +From the perspective of a Haskell programmer, however, it is best to +think of a monad as an abstract datatype of actions. +Haskell's do expressions provide a convenient syntax for writing +monadic expressions. +

Minimal complete definition: >>= and return. +

Instances of Monad should satisfy the following laws: +

return a >>= k == k a + m >>= return == m + m >>= (\x -> k x >>= h) == (m >>= k) >>= h +

Instances of both Monad and Functor should additionally satisfy the law: +

fmap f xs == xs >>= return . f +

The instances of Monad for lists, Data.Maybe.Maybe and System.IO.IO +defined in the Prelude satisfy these laws. +

Methods
(>>=) :: m a -> (a -> m b) -> m b
Sequentially compose two actions, passing any value produced + by the first as an argument to the second. +
(>>) :: m a -> m b -> m b
Sequentially compose two actions, discarding any value produced + by the first, like sequencing operators (such as the semicolon) + in imperative languages. +
return :: a -> m a
Inject a value into the monadic type. +
fail :: String -> m a
Fail with a message. This operation is not part of the + mathematical definition of a monad, but is invoked on pattern-match + failure in a do expression. +
show/hide Instances
runInteractiveProcess
:: FilePathFilename of the executable +
-> [String]Arguments to pass to the executable +
-> Maybe FilePathOptional path to the working directory +
-> Maybe [(String, String)]Optional environment (otherwise inherit) +
-> IO (Handle, Handle, Handle, ProcessHandle)

Runs a raw command, and returns Handles that may be used to communicate + with the process via its stdin, stdout and stderr respectively. +

For example, to start a process and feed a string to its stdin: +

(inp,out,err,pid) <- runInteractiveProcess "..." + forkIO (hPutStr inp str) +

The Handles are initially in binary mode; if you need them to be + in text mode then use hSetBinaryMode. +

Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/Examples.hs b/tests/golden-tests/tests/Examples.hs new file mode 100644 index 00000000..ed22b614 --- /dev/null +++ b/tests/golden-tests/tests/Examples.hs @@ -0,0 +1,34 @@ +module Examples where + +-- | Fibonacci number of given 'Integer'. +-- +-- Examples: +-- +-- ghci> fib 5 +-- 5 +-- ghci> fib 10 +-- 55 +-- +-- ghci> fib 10 +-- 55 +-- +-- One more Example: +-- +-- ghci> fib 5 +-- 5 +-- +-- One more Example: +-- +-- ghci> fib 5 +-- 5 +-- +-- Example with an import: +-- +-- ghci> import Data.Char +-- ghci> isSpace 'a' +-- False +-- +fib :: Integer -> Integer +fib 0 = 0 +fib 1 = 1 +fib n = fib (n - 1) + fib (n - 2) diff --git a/tests/golden-tests/tests/Examples.html.ref b/tests/golden-tests/tests/Examples.html.ref new file mode 100644 index 00000000..64634d26 --- /dev/null +++ b/tests/golden-tests/tests/Examples.html.ref @@ -0,0 +1,208 @@ + + +Examples
 ContentsIndex
Examples
Synopsis
fib :: Integer -> Integer
Documentation
fib :: Integer -> Integer

Fibonacci number of given Integer. +

Examples: +

ghci> fib 5
+5
+ghci> fib 10
+55
+
ghci> fib 10
+55
+

One more Example: +

ghci> fib 5
+5
+

One more Example: +

ghci> fib 5
+5
+

Example with an import: +

ghci> import Data.Char
+ghci> isSpace 'a'
+False
+
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/FunArgs.hs b/tests/golden-tests/tests/FunArgs.hs new file mode 100644 index 00000000..b34d84b7 --- /dev/null +++ b/tests/golden-tests/tests/FunArgs.hs @@ -0,0 +1,16 @@ +module FunArgs where + +f :: forall a. Ord a + => Int -- ^ First argument + -> a -- ^ Second argument + -> Bool -- ^ Third argument + -> (a -> a) -- ^ Fourth argument + -> () -- ^ Result +f = undefined + + +g :: a -- ^ First argument + -> b -- ^ Second argument + -> c -- ^ Third argument + -> d -- ^ Result +g = undefined diff --git a/tests/golden-tests/tests/FunArgs.html.ref b/tests/golden-tests/tests/FunArgs.html.ref new file mode 100644 index 00000000..f6c34bd4 --- /dev/null +++ b/tests/golden-tests/tests/FunArgs.html.ref @@ -0,0 +1,190 @@ + + +FunArgs
 ContentsIndex
FunArgs
Documentation
f
:: forall a . Ord a
=> IntFirst argument +
-> aSecond argument +
-> BoolThird argument +
-> (a -> a)Fourth argument +
-> ()Result +
g
:: aFirst argument +
-> bSecond argument +
-> cThird argument +
-> dResult +
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/GADTRecords.hs b/tests/golden-tests/tests/GADTRecords.hs new file mode 100644 index 00000000..a82cb381 --- /dev/null +++ b/tests/golden-tests/tests/GADTRecords.hs @@ -0,0 +1,12 @@ + +module GADTRecords (H1(..)) where + +-- | h1 +data H1 a b where + C1 :: H1 a b + C2 :: Ord a => [a] -> H1 a a + C3 { field :: Int -- ^ hello docs + } :: H1 Int Int + C4 { field2 :: a -- ^ hello2 docs + } :: H1 Int a + diff --git a/tests/golden-tests/tests/GADTRecords.html.ref b/tests/golden-tests/tests/GADTRecords.html.ref new file mode 100644 index 00000000..3875b1c6 --- /dev/null +++ b/tests/golden-tests/tests/GADTRecords.html.ref @@ -0,0 +1,288 @@ + + +GADTRecords
 ContentsIndex
GADTRecords
Synopsis
data H1 a b where
C1 :: H1 a b
C2 :: Ord a => [a] -> H1 a a
C3 :: {
field :: Int
} -> H1 Int Int
C4 :: {
field2 :: a
} -> H1 Int a
Documentation
data H1 a b where
h1 +
Constructors
C1 :: H1 a b
C2 :: Ord a => [a] -> H1 a a
C3 :: Int -> H1 Int Int
field :: Inthello docs +
C4 :: a -> H1 Int a
field2 :: ahello2 docs +
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/Hash.hs b/tests/golden-tests/tests/Hash.hs new file mode 100644 index 00000000..7d6506f9 --- /dev/null +++ b/tests/golden-tests/tests/Hash.hs @@ -0,0 +1,51 @@ +{- | + Implementation of fixed-size hash tables, with a type + class for constructing hash values for structured types. +-} +module Hash ( + -- * The @HashTable@ type + HashTable, + + -- ** Operations on @HashTable@s + new, insert, lookup, + + -- * The @Hash@ class + Hash(..), + ) where + +import Array +import Prelude hiding (lookup) + +-- | A hash table with keys of type @key@ and values of type @val@. +-- The type @key@ should be an instance of 'Eq'. +data HashTable key val = HashTable Int (Array Int [(key,val)]) + +-- | Builds a new hash table with a given size +new :: (Eq key, Hash key) => Int -> IO (HashTable key val) +new = undefined + +-- | Inserts a new element into the hash table +insert :: (Eq key, Hash key) => key -> val -> IO () +insert = undefined + +-- | Looks up a key in the hash table, returns @'Just' val@ if the key +-- was found, or 'Nothing' otherwise. +lookup :: Hash key => key -> IO (Maybe val) +lookup = undefined + +-- | A class of types which can be hashed. +class Hash a where + -- | hashes the value of type @a@ into an 'Int' + hash :: a -> Int + +instance Hash Int where + hash = id + +instance Hash Float where + hash = trunc + +instance (Hash a, Hash b) => Hash (a,b) where + hash (a,b) = hash a `xor` hash b + +trunc = undefined +xor = undefined diff --git a/tests/golden-tests/tests/Hash.html.ref b/tests/golden-tests/tests/Hash.html.ref new file mode 100644 index 00000000..3362368a --- /dev/null +++ b/tests/golden-tests/tests/Hash.html.ref @@ -0,0 +1,476 @@ + + +Hash
 ContentsIndex
Hash
Contents
The HashTable type +
Operations on HashTables +
The Hash class +
Description
Implementation of fixed-size hash tables, with a type + class for constructing hash values for structured types. +
Synopsis
data HashTable key val
new :: (Eq key, Hash key) => Int -> IO (HashTable key val)
insert :: (Eq key, Hash key) => key -> val -> IO ()
lookup :: Hash key => key -> IO (Maybe val)
class Hash a where
hash :: a -> Int
The HashTable type +
data HashTable key val
A hash table with keys of type key and values of type val. + The type key should be an instance of Eq. +
Operations on HashTables +
new :: (Eq key, Hash key) => Int -> IO (HashTable key val)
Builds a new hash table with a given size +
insert :: (Eq key, Hash key) => key -> val -> IO ()
Inserts a new element into the hash table +
lookup :: Hash key => key -> IO (Maybe val)
Looks up a key in the hash table, returns Just val if the key + was found, or Nothing otherwise. +
The Hash class +
class Hash a where
A class of types which can be hashed. +
Methods
hash :: a -> Int
hashes the value of type a into an Int +
show/hide Instances
Hash Float
Hash Int
(Hash a, Hash b) => Hash (a, b)
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/Hidden.hs b/tests/golden-tests/tests/Hidden.hs new file mode 100644 index 00000000..896da648 --- /dev/null +++ b/tests/golden-tests/tests/Hidden.hs @@ -0,0 +1,6 @@ +{-# OPTIONS_HADDOCK hide #-} + +module Hidden where + +hidden :: Int -> Int +hidden a = a diff --git a/tests/golden-tests/tests/NamedDoc.hs b/tests/golden-tests/tests/NamedDoc.hs new file mode 100644 index 00000000..7c04ba72 --- /dev/null +++ b/tests/golden-tests/tests/NamedDoc.hs @@ -0,0 +1,4 @@ +module NamedDoc where + +-- $foo bar + diff --git a/tests/golden-tests/tests/NamedDoc.html.ref b/tests/golden-tests/tests/NamedDoc.html.ref new file mode 100644 index 00000000..3b1b7f1e --- /dev/null +++ b/tests/golden-tests/tests/NamedDoc.html.ref @@ -0,0 +1,98 @@ + + +NamedDoc
 ContentsIndex
NamedDoc
Synopsis
Documentation
bar +
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/NoLayout.hs b/tests/golden-tests/tests/NoLayout.hs new file mode 100644 index 00000000..ac8e58bb --- /dev/null +++ b/tests/golden-tests/tests/NoLayout.hs @@ -0,0 +1,12 @@ + +-- Haddock comments are parsed as separate declarations so we +-- need to insert a ';' when using them with explicit layout. +-- This should probably be changed. + +module NoLayout where { + -- | the class 'C' + ; + g :: Int; + g = undefined + } + diff --git a/tests/golden-tests/tests/NoLayout.html.ref b/tests/golden-tests/tests/NoLayout.html.ref new file mode 100644 index 00000000..7b365bd1 --- /dev/null +++ b/tests/golden-tests/tests/NoLayout.html.ref @@ -0,0 +1,115 @@ + + +NoLayout
 ContentsIndex
NoLayout
Synopsis
g :: Int
Documentation
g :: Int
the class C +
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/NonGreedy.hs b/tests/golden-tests/tests/NonGreedy.hs new file mode 100644 index 00000000..f51b55f5 --- /dev/null +++ b/tests/golden-tests/tests/NonGreedy.hs @@ -0,0 +1,5 @@ +module NonGreedy where + +-- | +f :: a +f = undefined diff --git a/tests/golden-tests/tests/NonGreedy.html.ref b/tests/golden-tests/tests/NonGreedy.html.ref new file mode 100644 index 00000000..670fc34a --- /dev/null +++ b/tests/golden-tests/tests/NonGreedy.html.ref @@ -0,0 +1,115 @@ + + +NonGreedy
 ContentsIndex
NonGreedy
Synopsis
f :: a
Documentation
f :: a
url1 url2 +
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/QuasiExpr.hs b/tests/golden-tests/tests/QuasiExpr.hs new file mode 100644 index 00000000..6fc00a72 --- /dev/null +++ b/tests/golden-tests/tests/QuasiExpr.hs @@ -0,0 +1,36 @@ +{-# LANGUAGE TemplateHaskell #-} + +-- Used by QuasiQuote. Example taken from the GHC documentation. +module QuasiExpr where + +import Language.Haskell.TH +import Language.Haskell.TH.Quote +import Data.Typeable +import Data.Generics + +data Expr = IntExpr Integer + | AntiIntExpr String + | BinopExpr BinOp Expr Expr + | AntiExpr String + deriving(Show, Typeable, Data) + +data BinOp = AddOp + | SubOp + | MulOp + | DivOp + deriving(Show, Typeable, Data) + +eval :: Expr -> Integer +eval (IntExpr n) = n +eval (BinopExpr op x y) = (opToFun op) (eval x) (eval y) + where + opToFun AddOp = (+) + opToFun SubOp = (-) + opToFun MulOp = (*) + opToFun DivOp = div + +expr = QuasiQuoter parseExprExp undefined + +-- cheating... +parseExprExp :: String -> Q Exp +parseExprExp _ = [| BinopExpr AddOp (IntExpr 1) (IntExpr 2) |] diff --git a/tests/golden-tests/tests/QuasiExpr.html.ref b/tests/golden-tests/tests/QuasiExpr.html.ref new file mode 100644 index 00000000..2cb316b1 --- /dev/null +++ b/tests/golden-tests/tests/QuasiExpr.html.ref @@ -0,0 +1,346 @@ + + +QuasiExpr
 ContentsIndex
QuasiExpr
Documentation
data Expr
Constructors
IntExpr Integer
AntiIntExpr String
BinopExpr BinOp Expr Expr
AntiExpr String
show/hide Instances
data BinOp
Constructors
AddOp
SubOp
MulOp
DivOp
show/hide Instances
eval :: Expr -> Integer
parseExprExp :: String -> Q Exp
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/QuasiQuote.hs b/tests/golden-tests/tests/QuasiQuote.hs new file mode 100644 index 00000000..ed3c3787 --- /dev/null +++ b/tests/golden-tests/tests/QuasiQuote.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE TemplateHaskell, QuasiQuotes #-} + +-- example taken from the GHC documentation +module QuasiQuote where + +import QuasiExpr + +val :: Integer +val = eval [$expr|1 + 2|] diff --git a/tests/golden-tests/tests/QuasiQuote.html.ref b/tests/golden-tests/tests/QuasiQuote.html.ref new file mode 100644 index 00000000..4de6086b --- /dev/null +++ b/tests/golden-tests/tests/QuasiQuote.html.ref @@ -0,0 +1,90 @@ + + +QuasiQuote
 ContentsIndex
QuasiQuote
Documentation
val :: Integer
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/TH.hs b/tests/golden-tests/tests/TH.hs new file mode 100644 index 00000000..f8178bcb --- /dev/null +++ b/tests/golden-tests/tests/TH.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} + +module TH where + +import Language.Haskell.TH + +decl :: Q [Dec] +decl = [d| f x = x|] diff --git a/tests/golden-tests/tests/TH.html.ref b/tests/golden-tests/tests/TH.html.ref new file mode 100644 index 00000000..4d2e0b09 --- /dev/null +++ b/tests/golden-tests/tests/TH.html.ref @@ -0,0 +1,89 @@ + + +TH
 ContentsIndex
TH
Documentation
decl :: Q [Dec]
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/TH2.hs b/tests/golden-tests/tests/TH2.hs new file mode 100644 index 00000000..f8f27710 --- /dev/null +++ b/tests/golden-tests/tests/TH2.hs @@ -0,0 +1,8 @@ +{-# LANGUAGE TemplateHaskell #-} + +module TH2 where + +import TH + +-- we can't add a type sig here, so we get no doc +$( decl ) diff --git a/tests/golden-tests/tests/TH2.html.ref b/tests/golden-tests/tests/TH2.html.ref new file mode 100644 index 00000000..f7aaf18f --- /dev/null +++ b/tests/golden-tests/tests/TH2.html.ref @@ -0,0 +1,71 @@ + + +TH2
 ContentsIndex
TH2
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/Test.hs b/tests/golden-tests/tests/Test.hs new file mode 100644 index 00000000..230f32d8 --- /dev/null +++ b/tests/golden-tests/tests/Test.hs @@ -0,0 +1,410 @@ +----------------------------------------------------------------------------- +-- | +-- 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 +import Data.Maybe + +bla = Nothing + +-- | 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: . +-} + +f :: C a => a -> Int + +-- | we can export foreign declarations too +foreign import ccall 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 + 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/tests/golden-tests/tests/Test.html.ref b/tests/golden-tests/tests/Test.html.ref new file mode 100644 index 00000000..3c839612 --- /dev/null +++ b/tests/golden-tests/tests/Test.html.ref @@ -0,0 +1,3110 @@ + + +Test
 ContentsIndex
Test
Portabilityportable
Stabilityprovisional
Maintainerlibraries@haskell.org
Contents
Type declarations +
Data types +
Records +
Class declarations +
Function types +
Auxiliary stuff +
A hidden module +
A visible module +
Existential / Universal types +
Type signatures with argument docs +
A section +
A subsection +
Description
This module illustrates & tests most of the features of Haddock. + Testing references from the description: T, f, g, visible. +
Synopsis
data T a b
= A Int (Maybe Float)
| B (T a b, T Int Float)
data T2 a b
data T3 a b
= A1 a
| B1 b
data T4 a b
= A2 a
| B2 b
data T5 a b
= A3 a
| B3 b
data T6
= A4
| B4
| C4
newtype N1 a = N1 a
newtype N2 a b = N2 {
n :: a b
}
newtype N3 a b = N3 {
n3 :: a b
}
data N4 a b
newtype N5 a b = N5 {
n5 :: a b
}
newtype N6 a b = N6 {
n6 :: a b
}
newtype N7 a b = N7 {
n7 :: a b
}
data R
= C1 {
p :: Int
q :: forall a. a -> a
r :: Int
s :: Int
}
| C2 {
t :: T1 -> T2 Int Int -> T3 Bool Bool -> T4 Float Float -> T5 () ()
u :: Int
v :: Int
}
data R1 = C3 {
s1 :: Int
s2 :: Int
s3 :: Int
}
class D a => C a where
a :: IO a
b :: [a]
class D a where
d :: T a b
e :: (a, a)
class E a
class F a where
ff :: a
f :: C a => a -> Int
g :: Int -> IO CInt
hidden :: Int -> Int
module Visible
data Ex a
= forall b . C b => Ex1 b
| forall b . Ex2 b
| forall b . C a => Ex3 b
| Ex4 (forall a. a -> a)
k :: T () () -> T2 Int Int -> (T3 Bool Bool -> T4 Float Float) -> T5 () () -> IO ()
l :: (Int, Int, Float) -> Int
m :: R -> N1 () -> IO Int
o :: Float -> IO Float
f' :: Int
Type declarations +
Data types +
data T a b
This comment applies to the following declaration + and it continues until the next non-comment line +
Constructors
A Int (Maybe Float)This comment describes the A constructor +
B (T a b, T Int Float)This comment describes the B constructor +
data T2 a b
An abstract data declaration +
data T3 a b
A data declaration with no documentation annotations on the constructors +
Constructors
A1 a
B1 b
data T4 a b
Constructors
A2 a
B2 b
data T5 a b
Constructors
A3 adocuments A3 +
B3 bdocuments B3 +
data T6
Testing alternative comment styles +
Constructors
A4This is the doc for A4 +
B4This is the doc for B4 +
C4This is the doc for C4 +
newtype N1 a
A newtype +
Constructors
N1 a
newtype N2 a b
A newtype with a fieldname +
Constructors
N2
n :: a b
newtype N3 a b
A newtype with a fieldname, documentation on the field +
Constructors
N3
n3 :: a bthis is the n3 field +
data N4 a b
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 N5 a b
Constructors
N5
n5 :: a bno docs on the datatype or the constructor +
newtype N6 a b
Constructors
N6docs on the constructor only +
n6 :: a b
newtype N7 a b
docs on the newtype and the constructor +
Constructors
N7The N7 constructor +
n7 :: a b
Records +
data R
This is the documentation for the R record, which has four fields, + p, q, r, and s. +
Constructors
C1This is the C1 record constructor, with the following fields: +
p :: IntThis comment applies to the p field +
q :: forall a. a -> aThis comment applies to the q field +
r :: IntThis comment applies to both r and s +
s :: IntThis comment applies to both r and s +
C2This is the C2 record constructor, also with some fields: +
t :: T1 -> T2 Int Int -> T3 Bool Bool -> T4 Float Float -> T5 () ()
u :: Int
v :: Int
data R1
Testing different record commenting styles +
Constructors
C3This is the C3 record constructor +
s1 :: IntThe s1 record selector +
s2 :: IntThe s2 record selector +
s3 :: IntThe s3 record selector +
test that we can export record selectors on their own: +
Class declarations +
class D a => C a where
This comment applies to the previous declaration (the C class) +
Methods
a :: IO a
this is a description of the a method +
b :: [a]
this is a description of the b method +
class D a where
This is a class declaration with no separate docs for the methods +
Methods
d :: T a b
e :: (a, a)
show/hide Instances
class E a
This is a class declaration with no methods (or no methods exported) +
class F a where
Methods
ff :: a
Test that we can export a class method on its own: +
Function types +
f :: C a => a -> Int

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/. +

g :: Int -> IO CInt
we can export foreign declarations too +
Auxiliary stuff +

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
This is some documentation that is attached to a name ($aux2) +
 code block on its own in named doc
 code block on its own in named doc (after newline)

a nested, named doc comment +

with a paragraph, +

 and a code block
test
+test1
+
 test2
+  test3
+
+test1
+test2
+
test3
+test4
+
+test1
+test2
+
test3
+test4
+
test3
+test4
+
+test1
+test2
+

aux11: +

test3
+test4
+
+test1
+test2
+
 foo
+
 bar
+

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 +
hidden :: Int -> Int
A visible module +
module Visible
nested-style doc comments +
Existential / Universal types +
data Ex a
A data-type using existential/universal types +
Constructors
forall b . C b => Ex1 b
forall b . Ex2 b
forall b . C a => Ex3 b
Ex4 (forall a. a -> a)
Type signatures with argument docs +
k
:: T () ()This argument has type T +
-> T2 Int IntThis 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 is a function with documentation for each argument +
l
:: (Int, Int, Float)takes a triple +
-> Intreturns an Int +
m
:: R
-> N1 ()one of the arguments +
-> IO Intand the return value +
This function has some arg docs +
o
:: FloatThe input float +
-> IO FloatThe output float +
A foreign import with argument docs +
A section +
A subsection +
 a literal line
+

$ a non literal line $ +

f' :: Int
a function with a prime can be referred to as f' + but f' doesn't get link'd 'f\'' +
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/Ticket112.hs b/tests/golden-tests/tests/Ticket112.hs new file mode 100644 index 00000000..c9cd5117 --- /dev/null +++ b/tests/golden-tests/tests/Ticket112.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE MagicHash #-} + +module Ticket112 where + +import GHC.Prim + +-- | ...given a raw 'Addr#' to the string, and the length of the string. +f :: a +f = undefined diff --git a/tests/golden-tests/tests/Ticket112.html.ref b/tests/golden-tests/tests/Ticket112.html.ref new file mode 100644 index 00000000..9ff3a192 --- /dev/null +++ b/tests/golden-tests/tests/Ticket112.html.ref @@ -0,0 +1,116 @@ + + +Ticket112
 ContentsIndex
Ticket112
Synopsis
f :: a
Documentation
f :: a
...given a raw Addr# to the string, and the length of the string. +
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/Ticket61.hs b/tests/golden-tests/tests/Ticket61.hs new file mode 100644 index 00000000..26ca287f --- /dev/null +++ b/tests/golden-tests/tests/Ticket61.hs @@ -0,0 +1,3 @@ +module Ticket61 (module Ticket61_Hidden) where + +import Ticket61_Hidden diff --git a/tests/golden-tests/tests/Ticket61.html.ref b/tests/golden-tests/tests/Ticket61.html.ref new file mode 100644 index 00000000..7931bbf8 --- /dev/null +++ b/tests/golden-tests/tests/Ticket61.html.ref @@ -0,0 +1,128 @@ + + +Ticket61
 ContentsIndex
Ticket61
Documentation
class C a where
Methods
f :: a
A comment about f +
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/Ticket61_Hidden.hs b/tests/golden-tests/tests/Ticket61_Hidden.hs new file mode 100644 index 00000000..583c10cd --- /dev/null +++ b/tests/golden-tests/tests/Ticket61_Hidden.hs @@ -0,0 +1,7 @@ +{-# OPTIONS_HADDOCK hide #-} + +module Ticket61_Hidden where + +class C a where + -- | A comment about f + f :: a diff --git a/tests/golden-tests/tests/Ticket75.hs b/tests/golden-tests/tests/Ticket75.hs new file mode 100644 index 00000000..94a2f115 --- /dev/null +++ b/tests/golden-tests/tests/Ticket75.hs @@ -0,0 +1,7 @@ +module Ticket75 where + +data a :- b = Q + +-- | A reference to ':-' +f :: Int +f = undefined diff --git a/tests/golden-tests/tests/Ticket75.html.ref b/tests/golden-tests/tests/Ticket75.html.ref new file mode 100644 index 00000000..1490c1dc --- /dev/null +++ b/tests/golden-tests/tests/Ticket75.html.ref @@ -0,0 +1,174 @@ + + +Ticket75
 ContentsIndex
Ticket75
Synopsis
data a :- b = Q
f :: Int
Documentation
data a :- b
Constructors
Q
f :: Int
A reference to :- +
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/TypeFamilies.hs b/tests/golden-tests/tests/TypeFamilies.hs new file mode 100644 index 00000000..561f95fd --- /dev/null +++ b/tests/golden-tests/tests/TypeFamilies.hs @@ -0,0 +1,28 @@ +{-# LANGUAGE TypeFamilies #-} + +module TypeFamilies where + +-- | Type family G +type family G a :: * + +-- | A class with an associated type +class A a where + -- | An associated type + data B a :: * -> * + -- | A method + f :: B a Int + +-- | Doc for family +type family F a + + +-- | Doc for G Int +type instance G Int = Bool +type instance G Float = Int + + +instance A Int where + data B Int x = Con x + f = Con 3 + +g = Con 5 diff --git a/tests/golden-tests/tests/TypeFamilies.html.ref b/tests/golden-tests/tests/TypeFamilies.html.ref new file mode 100644 index 00000000..101c5c80 --- /dev/null +++ b/tests/golden-tests/tests/TypeFamilies.html.ref @@ -0,0 +1,316 @@ + + +TypeFamilies
 ContentsIndex
TypeFamilies
Synopsis
type family G a :: *
class A a where
data B a :: * -> *
f :: B a Int
type family F a
Documentation
type family G a :: *
Type family G +
class A a where
A class with an associated type +
Associated Types
data B a :: * -> *
An associated type +
Methods
f :: B a Int
A method +
show/hide Instances
type family F a
Doc for family +
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/TypeOperators.hs b/tests/golden-tests/tests/TypeOperators.hs new file mode 100644 index 00000000..aa0fbe8c --- /dev/null +++ b/tests/golden-tests/tests/TypeOperators.hs @@ -0,0 +1,22 @@ +module TypeOperators ( + -- * stuff + (:-:), + (:+:), + Op, + O(..), + biO, + Flip(..) +) where + +data a :-: b + +data (a :+: b) c + +data a `Op` b + +newtype (g `O` f) a = O { unO :: g (f a) } + +biO :: (g `O` f) a +biO = undefined + +newtype Flip (~>) b a = Flip { unFlip :: a ~> b } diff --git a/tests/golden-tests/tests/TypeOperators.html.ref b/tests/golden-tests/tests/TypeOperators.html.ref new file mode 100644 index 00000000..787737e7 --- /dev/null +++ b/tests/golden-tests/tests/TypeOperators.html.ref @@ -0,0 +1,388 @@ + + +TypeOperators
 ContentsIndex
TypeOperators
Contents
stuff +
Synopsis
data a :-: b
data (a :+: b) c
data Op a b
newtype O g f a = O {
unO :: g (f a)
}
biO :: (g `O` f) a
newtype Flip (~>) b a = Flip {
unFlip :: a ~> b
}
stuff +
data a :-: b
data (a :+: b) c
data Op a b
newtype O g f a
Constructors
O
unO :: g (f a)
biO :: (g `O` f) a
newtype Flip (~>) b a
Constructors
Flip
unFlip :: a ~> b
Produced by Haddock version 2.7.2
diff --git a/tests/golden-tests/tests/Visible.hs b/tests/golden-tests/tests/Visible.hs new file mode 100644 index 00000000..cad71931 --- /dev/null +++ b/tests/golden-tests/tests/Visible.hs @@ -0,0 +1,3 @@ +module Visible where +visible :: Int -> Int +visible a = a diff --git a/tests/golden-tests/tests/Visible.html.ref b/tests/golden-tests/tests/Visible.html.ref new file mode 100644 index 00000000..5a16acb0 --- /dev/null +++ b/tests/golden-tests/tests/Visible.html.ref @@ -0,0 +1,91 @@ + + +Visible
 ContentsIndex
Visible
Documentation
visible :: Int -> Int
Produced by Haddock version 2.7.2
diff --git a/tests/parsetests.hs b/tests/parsetests.hs deleted file mode 100644 index f66355e2..00000000 --- a/tests/parsetests.hs +++ /dev/null @@ -1,56 +0,0 @@ -module Main (main) where - -import Test.HUnit -import RdrName (RdrName) -import DynFlags (defaultDynFlags) -import Haddock.Lex (tokenise) -import Haddock.Parse (parseParas) -import Haddock.Types - -instance Show RdrName where - show x = "RdrName" - -data ParseTest = ParseTest { - input :: String - , result :: (Maybe (Doc RdrName)) - } - -tests :: [ParseTest] -tests = [ - ParseTest { - input = "foobar" - , result = Just $ DocParagraph $ DocString "foobar\n" - } - - , ParseTest { - input = "foobar\n\nghci> fib 10\n55" - , result = Just $ DocAppend (DocParagraph $ DocString "foobar\n") (DocExamples $ [Example "fib 10" ["55"]]) - } - - , ParseTest { - input = "foobar\nghci> fib 10\n55" - , result = Nothing -- parse error - } - - , ParseTest { - input = "foobar\n\n> some code" - , result = Just (DocAppend (DocParagraph (DocString "foobar\n")) (DocCodeBlock (DocString " some code\n"))) - } - - , ParseTest { - input = "foobar\n> some code" - , result = Nothing -- parse error - } - ] - - -main = do - _ <- runTestTT $ TestList $ map testFromParseTest tests - return (); - where - - testFromParseTest :: ParseTest -> Test - testFromParseTest (ParseTest input result) = TestCase $ assertEqual input (parse input) result - - parse :: String -> Maybe (Doc RdrName) - parse input = parseParas $ tokenise defaultDynFlags input (0,0) diff --git a/tests/runparsetests.sh b/tests/runparsetests.sh deleted file mode 100644 index f02d3f1c..00000000 --- a/tests/runparsetests.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -cd `dirname $0` - -runhaskell -hide-all-packages -cpp \ - -packagecontainers \ - -packagearray \ - -packagebase \ - -packageghc \ - -packagexhtml \ - -packageghc-paths \ - -packageHUnit \ - -i../dist/build/ \ - -i../src/ \ - parsetests.hs diff --git a/tests/runtests.hs b/tests/runtests.hs deleted file mode 100644 index 99a47828..00000000 --- a/tests/runtests.hs +++ /dev/null @@ -1,114 +0,0 @@ -import System.Cmd -import System.Environment -import System.FilePath -import System.Exit -import System.Directory -import System.Process -import Data.List -import Control.Monad -import Text.Printf -import Text.Regex -import Distribution.Simple.Utils -import Distribution.Simple.Program -import Distribution.Verbosity -import Data.Maybe - - -haddockPath = ".." "dist" "build" "haddock" "haddock" - - -main = do - test - putStrLn "All tests passed!" - - -test = do - x <- doesFileExist haddockPath - when (not x) $ die "you need to run 'cabal build' successfully first" - - contents <- getDirectoryContents "tests" - args <- getArgs - let (opts, spec) = span ("-" `isPrefixOf`) args - let mods = - case spec of - x:_ | x /= "all" -> [x ++ ".hs"] - _ -> filter ((==) ".hs" . takeExtension) contents - - let outdir = "output" - let mods' = map ("tests" ) mods - putStrLn "" - putStrLn "Haddock version: " - h1 <- runProcess haddockPath ["--version"] Nothing - (Just [("haddock_datadir", "../.")]) Nothing Nothing Nothing - waitForProcess h1 - putStrLn "" - putStrLn "GHC version: " - h2 <- runProcess haddockPath ["--ghc-version"] Nothing - (Just [("haddock_datadir", "../.")]) Nothing Nothing Nothing - waitForProcess h2 - putStrLn "" - - -- TODO: use Distribution.* to get the packages instead - libdir <- rawSystemStdout normal haddockPath ["--print-ghc-libdir"] - let librariesPath = "..""..""share""doc""ghc""html""libraries" - - let mkDep name version = - let path = init libdir librariesPath name ++ "-" ++ version - in "-i " ++ path ++ "," ++ path name ++ ".haddock" - - let base = mkDep "base" "4.2.0.0" - process = mkDep "process" "1.0.1.2" - ghcprim = mkDep "ghc-prim" "0.2.0.0" - - putStrLn "Running tests..." - handle <- runProcess haddockPath - (["-w", "-o", outdir, "-h", "--optghc=-fglasgow-exts" - , "--optghc=-w", base, process, ghcprim] ++ opts ++ mods') - Nothing (Just [("haddock_datadir", "../.")]) Nothing - Nothing Nothing - - code <- waitForProcess handle - when (code /= ExitSuccess) $ error "Haddock run failed! Exiting." - check mods (if not (null args) && args !! 0 == "all" then False else True) - - -check modules strict = do - forM_ modules $ \mod -> do - let outfile = "output" (dropExtension mod ++ ".html") - let reffile = "tests" dropExtension mod ++ ".html.ref" - b <- doesFileExist reffile - if b - then do - copyFile reffile ("output" takeFileName reffile) - out <- readFile outfile - ref <- readFile reffile - if not $ haddockEq out ref - then do - putStrLn $ "Output for " ++ mod ++ " has changed! Exiting with diff:" - let ref' = stripLinks ref - out' = stripLinks out - let reffile' = "output" takeFileName reffile ++ ".nolinks" - outfile' = "output" takeFileName outfile ++ ".nolinks" - writeFile reffile' ref' - writeFile outfile' out' - b <- programOnPath "colordiff" - if b - then system $ "colordiff " ++ reffile' ++ " " ++ outfile' - else system $ "diff " ++ reffile' ++ " " ++ outfile' - if strict then exitFailure else return () - else do - putStrLn $ "Pass: " ++ mod - else do - putStrLn $ "Pass: " ++ mod ++ " (no .ref file)" - - -haddockEq file1 file2 = stripLinks file1 == stripLinks file2 - - -stripLinks f = subRegex (mkRegexWithOpts "
]*>" False False) f "" - - -programOnPath p = do - result <- findProgramLocation silent p - return (isJust result) - diff --git a/tests/tests/A.hs b/tests/tests/A.hs deleted file mode 100644 index 4a344a24..00000000 --- a/tests/tests/A.hs +++ /dev/null @@ -1,2 +0,0 @@ -module A where -data A = A diff --git a/tests/tests/A.html.ref b/tests/tests/A.html.ref deleted file mode 100644 index 69567351..00000000 --- a/tests/tests/A.html.ref +++ /dev/null @@ -1,119 +0,0 @@ - - -A
 ContentsIndex
A
Documentation
data A
Constructors
A
Produced by Haddock version 2.7.2
diff --git a/tests/tests/B.hs b/tests/tests/B.hs deleted file mode 100644 index 3a31507e..00000000 --- a/tests/tests/B.hs +++ /dev/null @@ -1,2 +0,0 @@ -module B ( module A ) where -import A diff --git a/tests/tests/B.html.ref b/tests/tests/B.html.ref deleted file mode 100644 index 007d084b..00000000 --- a/tests/tests/B.html.ref +++ /dev/null @@ -1,84 +0,0 @@ - - -B
 ContentsIndex
B
Documentation
module A
Produced by Haddock version 2.7.2
diff --git a/tests/tests/Bug1.hs b/tests/tests/Bug1.hs deleted file mode 100644 index af1ed4d3..00000000 --- a/tests/tests/Bug1.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Bug1 where - --- | We should have different anchors for constructors and types\/classes. This --- hyperlink should point to the type constructor by default: 'T'. -data T = T - diff --git a/tests/tests/Bug1.html.ref b/tests/tests/Bug1.html.ref deleted file mode 100644 index 861b7ee7..00000000 --- a/tests/tests/Bug1.html.ref +++ /dev/null @@ -1,150 +0,0 @@ - - -Bug1
 ContentsIndex
Bug1
Synopsis
data T = T
Documentation
data T
We should have different anchors for constructors and types/classes. This - hyperlink should point to the type constructor by default: T. -
Constructors
T
Produced by Haddock version 2.7.2
diff --git a/tests/tests/Bug2.hs b/tests/tests/Bug2.hs deleted file mode 100644 index 9121922e..00000000 --- a/tests/tests/Bug2.hs +++ /dev/null @@ -1,4 +0,0 @@ -module Bug2 ( x ) where -import B -x :: A -x = A diff --git a/tests/tests/Bug2.html.ref b/tests/tests/Bug2.html.ref deleted file mode 100644 index e344bd69..00000000 --- a/tests/tests/Bug2.html.ref +++ /dev/null @@ -1,90 +0,0 @@ - - -Bug2
 ContentsIndex
Bug2
Documentation
x :: A
Produced by Haddock version 2.7.2
diff --git a/tests/tests/Bug3.hs b/tests/tests/Bug3.hs deleted file mode 100644 index 67e57892..00000000 --- a/tests/tests/Bug3.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Bug3 where - --- | /multi-line --- emphasis/ -foo :: Int -foo = undefined diff --git a/tests/tests/Bug3.html.ref b/tests/tests/Bug3.html.ref deleted file mode 100644 index dc24ddd0..00000000 --- a/tests/tests/Bug3.html.ref +++ /dev/null @@ -1,116 +0,0 @@ - - -Bug3
 ContentsIndex
Bug3
Synopsis
foo :: Int
Documentation
foo :: Int
/multi-line - emphasis/ -
Produced by Haddock version 2.7.2
diff --git a/tests/tests/Bug4.hs b/tests/tests/Bug4.hs deleted file mode 100644 index 425a77aa..00000000 --- a/tests/tests/Bug4.hs +++ /dev/null @@ -1,5 +0,0 @@ -module Bug4 where --- | don't use apostrophe's in the wrong place's -foo :: Int -foo = undefined - diff --git a/tests/tests/Bug4.html.ref b/tests/tests/Bug4.html.ref deleted file mode 100644 index 1a09fff3..00000000 --- a/tests/tests/Bug4.html.ref +++ /dev/null @@ -1,115 +0,0 @@ - - -Bug4
 ContentsIndex
Bug4
Synopsis
foo :: Int
Documentation
foo :: Int
don't use apostrophe's in the wrong place's -
Produced by Haddock version 2.7.2
diff --git a/tests/tests/Bug6.hs b/tests/tests/Bug6.hs deleted file mode 100644 index 17411f31..00000000 --- a/tests/tests/Bug6.hs +++ /dev/null @@ -1,23 +0,0 @@ --- | Exporting records. -module Bug6( A(A), B(B), b, C(C,c1,c2), D(D,d1), E(E) ) where - --- | --- This record is exported without its field -data A = A { a :: Int } - --- | --- .. with its field, but the field is named separately in the export list --- (the field isn't documented separately since it is already documented here) -data B = B { b :: Int } - --- | --- .. with fields names as subordinate names in the export -data C = C { c1 :: Int, c2 :: Int } - --- | --- .. with only some of the fields exported (we can't handle this one - --- how do we render the declaration?) -data D = D { d1 :: Int, d2 :: Int } - --- | a newtype with a field -newtype E = E { e :: Int } diff --git a/tests/tests/Bug6.html.ref b/tests/tests/Bug6.html.ref deleted file mode 100644 index 3686fd6d..00000000 --- a/tests/tests/Bug6.html.ref +++ /dev/null @@ -1,482 +0,0 @@ - - -Bug6
 ContentsIndex
Bug6
Description
Exporting records. -
Synopsis
data A = A Int
data B = B {
b :: Int
}
data C = C {
c1 :: Int
c2 :: Int
}
data D = D Int Int
newtype E = E Int
Documentation
data A
This record is exported without its field -
Constructors
A Int
data B
.. with its field, but the field is named separately in the export list - (the field isn't documented separately since it is already documented here) -
Constructors
B
b :: Int
data C
.. with fields names as subordinate names in the export -
Constructors
C
c1 :: Int
c2 :: Int
data D
.. with only some of the fields exported (we can't handle this one - - how do we render the declaration?) -
Constructors
D Int Int
newtype E
a newtype with a field -
Constructors
E Int
Produced by Haddock version 2.7.2
diff --git a/tests/tests/Bug7.hs b/tests/tests/Bug7.hs deleted file mode 100644 index 8cf57914..00000000 --- a/tests/tests/Bug7.hs +++ /dev/null @@ -1,12 +0,0 @@ --- | This module caused a duplicate instance in the documentation for the Foo --- type. -module Bug7 where - --- | The Foo datatype -data Foo = Foo - --- | The Bar class -class Bar x y - --- | Just one instance -instance Bar Foo Foo diff --git a/tests/tests/Bug7.html.ref b/tests/tests/Bug7.html.ref deleted file mode 100644 index 83ce5323..00000000 --- a/tests/tests/Bug7.html.ref +++ /dev/null @@ -1,244 +0,0 @@ - - -Bug7
 ContentsIndex
Bug7
Description
This module caused a duplicate instance in the documentation for the Foo - type. -
Synopsis
data Foo = Foo
class Bar x y
Documentation
data Foo
The Foo datatype -
Constructors
Foo
show/hide Instances
Bar Foo FooJust one instance -
class Bar x y
The Bar class -
show/hide Instances
Bar Foo FooJust one instance -
Produced by Haddock version 2.7.2
diff --git a/tests/tests/Bug8.hs b/tests/tests/Bug8.hs deleted file mode 100644 index 0f279c29..00000000 --- a/tests/tests/Bug8.hs +++ /dev/null @@ -1,17 +0,0 @@ -{- Note that declarations without type signatures are not included in the - documentation. They could be, but that's a missing feature. -} - -module Bug8 where - -infix --> -infix ---> - -data Typ = Type (String,[Typ]) - | TFree (String, [String]) - -x --> y = Type("fun",[s,t]) -(--->) = flip $ foldr (-->) - -s = undefined -t = undefined -main = undefined diff --git a/tests/tests/Bug8.html.ref b/tests/tests/Bug8.html.ref deleted file mode 100644 index 907602b7..00000000 --- a/tests/tests/Bug8.html.ref +++ /dev/null @@ -1,135 +0,0 @@ - - -Bug8
 ContentsIndex
Bug8
Documentation
data Typ
Constructors
Type (String, [Typ])
TFree (String, [String])
Produced by Haddock version 2.7.2
diff --git a/tests/tests/Bugs.hs b/tests/tests/Bugs.hs deleted file mode 100644 index 8e1f0079..00000000 --- a/tests/tests/Bugs.hs +++ /dev/null @@ -1,3 +0,0 @@ -module Bugs where - -data A a = A a (a -> Int) diff --git a/tests/tests/Bugs.html.ref b/tests/tests/Bugs.html.ref deleted file mode 100644 index 75666af0..00000000 --- a/tests/tests/Bugs.html.ref +++ /dev/null @@ -1,120 +0,0 @@ - - -Bugs
 ContentsIndex
Bugs
Documentation
data A a
Constructors
A a (a -> Int)
Produced by Haddock version 2.7.2
diff --git a/tests/tests/CrossPackageDocs.hs b/tests/tests/CrossPackageDocs.hs deleted file mode 100644 index de55060e..00000000 --- a/tests/tests/CrossPackageDocs.hs +++ /dev/null @@ -1,3 +0,0 @@ -module CrossPackageDocs (map, Monad(..), runInteractiveProcess) where - -import System.Process diff --git a/tests/tests/CrossPackageDocs.html.ref b/tests/tests/CrossPackageDocs.html.ref deleted file mode 100644 index 375984dc..00000000 --- a/tests/tests/CrossPackageDocs.html.ref +++ /dev/null @@ -1,525 +0,0 @@ - - -CrossPackageDocs
 ContentsIndex
CrossPackageDocs
Synopsis
map :: (a -> b) -> [a] -> [b]
class Monad m where
(>>=) :: m a -> (a -> m b) -> m b
(>>) :: m a -> m b -> m b
return :: a -> m a
fail :: String -> m a
runInteractiveProcess :: FilePath -> [String] -> Maybe FilePath -> Maybe [(String, String)] -> IO (Handle, Handle, Handle, ProcessHandle)
Documentation
map :: (a -> b) -> [a] -> [b]

map f xs is the list obtained by applying f to each element - of xs, i.e., -

map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn] - map f [x1, x2, ...] == [f x1, f x2, ...] -
class Monad m where

The Monad class defines the basic operations over a monad, -a concept from a branch of mathematics known as category theory. -From the perspective of a Haskell programmer, however, it is best to -think of a monad as an abstract datatype of actions. -Haskell's do expressions provide a convenient syntax for writing -monadic expressions. -

Minimal complete definition: >>= and return. -

Instances of Monad should satisfy the following laws: -

return a >>= k == k a - m >>= return == m - m >>= (\x -> k x >>= h) == (m >>= k) >>= h -

Instances of both Monad and Functor should additionally satisfy the law: -

fmap f xs == xs >>= return . f -

The instances of Monad for lists, Data.Maybe.Maybe and System.IO.IO -defined in the Prelude satisfy these laws. -

Methods
(>>=) :: m a -> (a -> m b) -> m b
Sequentially compose two actions, passing any value produced - by the first as an argument to the second. -
(>>) :: m a -> m b -> m b
Sequentially compose two actions, discarding any value produced - by the first, like sequencing operators (such as the semicolon) - in imperative languages. -
return :: a -> m a
Inject a value into the monadic type. -
fail :: String -> m a
Fail with a message. This operation is not part of the - mathematical definition of a monad, but is invoked on pattern-match - failure in a do expression. -
show/hide Instances
runInteractiveProcess
:: FilePathFilename of the executable -
-> [String]Arguments to pass to the executable -
-> Maybe FilePathOptional path to the working directory -
-> Maybe [(String, String)]Optional environment (otherwise inherit) -
-> IO (Handle, Handle, Handle, ProcessHandle)

Runs a raw command, and returns Handles that may be used to communicate - with the process via its stdin, stdout and stderr respectively. -

For example, to start a process and feed a string to its stdin: -

(inp,out,err,pid) <- runInteractiveProcess "..." - forkIO (hPutStr inp str) -

The Handles are initially in binary mode; if you need them to be - in text mode then use hSetBinaryMode. -

Produced by Haddock version 2.7.2
diff --git a/tests/tests/Examples.hs b/tests/tests/Examples.hs deleted file mode 100644 index ed22b614..00000000 --- a/tests/tests/Examples.hs +++ /dev/null @@ -1,34 +0,0 @@ -module Examples where - --- | Fibonacci number of given 'Integer'. --- --- Examples: --- --- ghci> fib 5 --- 5 --- ghci> fib 10 --- 55 --- --- ghci> fib 10 --- 55 --- --- One more Example: --- --- ghci> fib 5 --- 5 --- --- One more Example: --- --- ghci> fib 5 --- 5 --- --- Example with an import: --- --- ghci> import Data.Char --- ghci> isSpace 'a' --- False --- -fib :: Integer -> Integer -fib 0 = 0 -fib 1 = 1 -fib n = fib (n - 1) + fib (n - 2) diff --git a/tests/tests/Examples.html.ref b/tests/tests/Examples.html.ref deleted file mode 100644 index 64634d26..00000000 --- a/tests/tests/Examples.html.ref +++ /dev/null @@ -1,208 +0,0 @@ - - -Examples
 ContentsIndex
Examples
Synopsis
fib :: Integer -> Integer
Documentation
fib :: Integer -> Integer

Fibonacci number of given Integer. -

Examples: -

ghci> fib 5
-5
-ghci> fib 10
-55
-
ghci> fib 10
-55
-

One more Example: -

ghci> fib 5
-5
-

One more Example: -

ghci> fib 5
-5
-

Example with an import: -

ghci> import Data.Char
-ghci> isSpace 'a'
-False
-
Produced by Haddock version 2.7.2
diff --git a/tests/tests/FunArgs.hs b/tests/tests/FunArgs.hs deleted file mode 100644 index b34d84b7..00000000 --- a/tests/tests/FunArgs.hs +++ /dev/null @@ -1,16 +0,0 @@ -module FunArgs where - -f :: forall a. Ord a - => Int -- ^ First argument - -> a -- ^ Second argument - -> Bool -- ^ Third argument - -> (a -> a) -- ^ Fourth argument - -> () -- ^ Result -f = undefined - - -g :: a -- ^ First argument - -> b -- ^ Second argument - -> c -- ^ Third argument - -> d -- ^ Result -g = undefined diff --git a/tests/tests/FunArgs.html.ref b/tests/tests/FunArgs.html.ref deleted file mode 100644 index f6c34bd4..00000000 --- a/tests/tests/FunArgs.html.ref +++ /dev/null @@ -1,190 +0,0 @@ - - -FunArgs
 ContentsIndex
FunArgs
Documentation
f
:: forall a . Ord a
=> IntFirst argument -
-> aSecond argument -
-> BoolThird argument -
-> (a -> a)Fourth argument -
-> ()Result -
g
:: aFirst argument -
-> bSecond argument -
-> cThird argument -
-> dResult -
Produced by Haddock version 2.7.2
diff --git a/tests/tests/GADTRecords.hs b/tests/tests/GADTRecords.hs deleted file mode 100644 index a82cb381..00000000 --- a/tests/tests/GADTRecords.hs +++ /dev/null @@ -1,12 +0,0 @@ - -module GADTRecords (H1(..)) where - --- | h1 -data H1 a b where - C1 :: H1 a b - C2 :: Ord a => [a] -> H1 a a - C3 { field :: Int -- ^ hello docs - } :: H1 Int Int - C4 { field2 :: a -- ^ hello2 docs - } :: H1 Int a - diff --git a/tests/tests/GADTRecords.html.ref b/tests/tests/GADTRecords.html.ref deleted file mode 100644 index 3875b1c6..00000000 --- a/tests/tests/GADTRecords.html.ref +++ /dev/null @@ -1,288 +0,0 @@ - - -GADTRecords
 ContentsIndex
GADTRecords
Synopsis
data H1 a b where
C1 :: H1 a b
C2 :: Ord a => [a] -> H1 a a
C3 :: {
field :: Int
} -> H1 Int Int
C4 :: {
field2 :: a
} -> H1 Int a
Documentation
data H1 a b where
h1 -
Constructors
C1 :: H1 a b
C2 :: Ord a => [a] -> H1 a a
C3 :: Int -> H1 Int Int
field :: Inthello docs -
C4 :: a -> H1 Int a
field2 :: ahello2 docs -
Produced by Haddock version 2.7.2
diff --git a/tests/tests/Hash.hs b/tests/tests/Hash.hs deleted file mode 100644 index 7d6506f9..00000000 --- a/tests/tests/Hash.hs +++ /dev/null @@ -1,51 +0,0 @@ -{- | - Implementation of fixed-size hash tables, with a type - class for constructing hash values for structured types. --} -module Hash ( - -- * The @HashTable@ type - HashTable, - - -- ** Operations on @HashTable@s - new, insert, lookup, - - -- * The @Hash@ class - Hash(..), - ) where - -import Array -import Prelude hiding (lookup) - --- | A hash table with keys of type @key@ and values of type @val@. --- The type @key@ should be an instance of 'Eq'. -data HashTable key val = HashTable Int (Array Int [(key,val)]) - --- | Builds a new hash table with a given size -new :: (Eq key, Hash key) => Int -> IO (HashTable key val) -new = undefined - --- | Inserts a new element into the hash table -insert :: (Eq key, Hash key) => key -> val -> IO () -insert = undefined - --- | Looks up a key in the hash table, returns @'Just' val@ if the key --- was found, or 'Nothing' otherwise. -lookup :: Hash key => key -> IO (Maybe val) -lookup = undefined - --- | A class of types which can be hashed. -class Hash a where - -- | hashes the value of type @a@ into an 'Int' - hash :: a -> Int - -instance Hash Int where - hash = id - -instance Hash Float where - hash = trunc - -instance (Hash a, Hash b) => Hash (a,b) where - hash (a,b) = hash a `xor` hash b - -trunc = undefined -xor = undefined diff --git a/tests/tests/Hash.html.ref b/tests/tests/Hash.html.ref deleted file mode 100644 index 3362368a..00000000 --- a/tests/tests/Hash.html.ref +++ /dev/null @@ -1,476 +0,0 @@ - - -Hash
 ContentsIndex
Hash
Contents
The HashTable type -
Operations on HashTables -
The Hash class -
Description
Implementation of fixed-size hash tables, with a type - class for constructing hash values for structured types. -
Synopsis
data HashTable key val
new :: (Eq key, Hash key) => Int -> IO (HashTable key val)
insert :: (Eq key, Hash key) => key -> val -> IO ()
lookup :: Hash key => key -> IO (Maybe val)
class Hash a where
hash :: a -> Int
The HashTable type -
data HashTable key val
A hash table with keys of type key and values of type val. - The type key should be an instance of Eq. -
Operations on HashTables -
new :: (Eq key, Hash key) => Int -> IO (HashTable key val)
Builds a new hash table with a given size -
insert :: (Eq key, Hash key) => key -> val -> IO ()
Inserts a new element into the hash table -
lookup :: Hash key => key -> IO (Maybe val)
Looks up a key in the hash table, returns Just val if the key - was found, or Nothing otherwise. -
The Hash class -
class Hash a where
A class of types which can be hashed. -
Methods
hash :: a -> Int
hashes the value of type a into an Int -
show/hide Instances
Hash Float
Hash Int
(Hash a, Hash b) => Hash (a, b)
Produced by Haddock version 2.7.2
diff --git a/tests/tests/Hidden.hs b/tests/tests/Hidden.hs deleted file mode 100644 index 896da648..00000000 --- a/tests/tests/Hidden.hs +++ /dev/null @@ -1,6 +0,0 @@ -{-# OPTIONS_HADDOCK hide #-} - -module Hidden where - -hidden :: Int -> Int -hidden a = a diff --git a/tests/tests/NamedDoc.hs b/tests/tests/NamedDoc.hs deleted file mode 100644 index 7c04ba72..00000000 --- a/tests/tests/NamedDoc.hs +++ /dev/null @@ -1,4 +0,0 @@ -module NamedDoc where - --- $foo bar - diff --git a/tests/tests/NamedDoc.html.ref b/tests/tests/NamedDoc.html.ref deleted file mode 100644 index 3b1b7f1e..00000000 --- a/tests/tests/NamedDoc.html.ref +++ /dev/null @@ -1,98 +0,0 @@ - - -NamedDoc
 ContentsIndex
NamedDoc
Synopsis
Documentation
bar -
Produced by Haddock version 2.7.2
diff --git a/tests/tests/NoLayout.hs b/tests/tests/NoLayout.hs deleted file mode 100644 index ac8e58bb..00000000 --- a/tests/tests/NoLayout.hs +++ /dev/null @@ -1,12 +0,0 @@ - --- Haddock comments are parsed as separate declarations so we --- need to insert a ';' when using them with explicit layout. --- This should probably be changed. - -module NoLayout where { - -- | the class 'C' - ; - g :: Int; - g = undefined - } - diff --git a/tests/tests/NoLayout.html.ref b/tests/tests/NoLayout.html.ref deleted file mode 100644 index 7b365bd1..00000000 --- a/tests/tests/NoLayout.html.ref +++ /dev/null @@ -1,115 +0,0 @@ - - -NoLayout
 ContentsIndex
NoLayout
Synopsis
g :: Int
Documentation
g :: Int
the class C -
Produced by Haddock version 2.7.2
diff --git a/tests/tests/NonGreedy.hs b/tests/tests/NonGreedy.hs deleted file mode 100644 index f51b55f5..00000000 --- a/tests/tests/NonGreedy.hs +++ /dev/null @@ -1,5 +0,0 @@ -module NonGreedy where - --- | -f :: a -f = undefined diff --git a/tests/tests/NonGreedy.html.ref b/tests/tests/NonGreedy.html.ref deleted file mode 100644 index 670fc34a..00000000 --- a/tests/tests/NonGreedy.html.ref +++ /dev/null @@ -1,115 +0,0 @@ - - -NonGreedy
 ContentsIndex
NonGreedy
Synopsis
f :: a
Documentation
f :: a
url1 url2 -
Produced by Haddock version 2.7.2
diff --git a/tests/tests/QuasiExpr.hs b/tests/tests/QuasiExpr.hs deleted file mode 100644 index 6fc00a72..00000000 --- a/tests/tests/QuasiExpr.hs +++ /dev/null @@ -1,36 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} - --- Used by QuasiQuote. Example taken from the GHC documentation. -module QuasiExpr where - -import Language.Haskell.TH -import Language.Haskell.TH.Quote -import Data.Typeable -import Data.Generics - -data Expr = IntExpr Integer - | AntiIntExpr String - | BinopExpr BinOp Expr Expr - | AntiExpr String - deriving(Show, Typeable, Data) - -data BinOp = AddOp - | SubOp - | MulOp - | DivOp - deriving(Show, Typeable, Data) - -eval :: Expr -> Integer -eval (IntExpr n) = n -eval (BinopExpr op x y) = (opToFun op) (eval x) (eval y) - where - opToFun AddOp = (+) - opToFun SubOp = (-) - opToFun MulOp = (*) - opToFun DivOp = div - -expr = QuasiQuoter parseExprExp undefined - --- cheating... -parseExprExp :: String -> Q Exp -parseExprExp _ = [| BinopExpr AddOp (IntExpr 1) (IntExpr 2) |] diff --git a/tests/tests/QuasiExpr.html.ref b/tests/tests/QuasiExpr.html.ref deleted file mode 100644 index 2cb316b1..00000000 --- a/tests/tests/QuasiExpr.html.ref +++ /dev/null @@ -1,346 +0,0 @@ - - -QuasiExpr
 ContentsIndex
QuasiExpr
Documentation
data Expr
Constructors
IntExpr Integer
AntiIntExpr String
BinopExpr BinOp Expr Expr
AntiExpr String
show/hide Instances
data BinOp
Constructors
AddOp
SubOp
MulOp
DivOp
show/hide Instances
eval :: Expr -> Integer
parseExprExp :: String -> Q Exp
Produced by Haddock version 2.7.2
diff --git a/tests/tests/QuasiQuote.hs b/tests/tests/QuasiQuote.hs deleted file mode 100644 index ed3c3787..00000000 --- a/tests/tests/QuasiQuote.hs +++ /dev/null @@ -1,9 +0,0 @@ -{-# LANGUAGE TemplateHaskell, QuasiQuotes #-} - --- example taken from the GHC documentation -module QuasiQuote where - -import QuasiExpr - -val :: Integer -val = eval [$expr|1 + 2|] diff --git a/tests/tests/QuasiQuote.html.ref b/tests/tests/QuasiQuote.html.ref deleted file mode 100644 index 4de6086b..00000000 --- a/tests/tests/QuasiQuote.html.ref +++ /dev/null @@ -1,90 +0,0 @@ - - -QuasiQuote
 ContentsIndex
QuasiQuote
Documentation
val :: Integer
Produced by Haddock version 2.7.2
diff --git a/tests/tests/TH.hs b/tests/tests/TH.hs deleted file mode 100644 index f8178bcb..00000000 --- a/tests/tests/TH.hs +++ /dev/null @@ -1,8 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} - -module TH where - -import Language.Haskell.TH - -decl :: Q [Dec] -decl = [d| f x = x|] diff --git a/tests/tests/TH.html.ref b/tests/tests/TH.html.ref deleted file mode 100644 index 4d2e0b09..00000000 --- a/tests/tests/TH.html.ref +++ /dev/null @@ -1,89 +0,0 @@ - - -TH
 ContentsIndex
TH
Documentation
decl :: Q [Dec]
Produced by Haddock version 2.7.2
diff --git a/tests/tests/TH2.hs b/tests/tests/TH2.hs deleted file mode 100644 index f8f27710..00000000 --- a/tests/tests/TH2.hs +++ /dev/null @@ -1,8 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} - -module TH2 where - -import TH - --- we can't add a type sig here, so we get no doc -$( decl ) diff --git a/tests/tests/TH2.html.ref b/tests/tests/TH2.html.ref deleted file mode 100644 index f7aaf18f..00000000 --- a/tests/tests/TH2.html.ref +++ /dev/null @@ -1,71 +0,0 @@ - - -TH2
 ContentsIndex
TH2
Produced by Haddock version 2.7.2
diff --git a/tests/tests/Test.hs b/tests/tests/Test.hs deleted file mode 100644 index 230f32d8..00000000 --- a/tests/tests/Test.hs +++ /dev/null @@ -1,410 +0,0 @@ ------------------------------------------------------------------------------ --- | --- 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 -import Data.Maybe - -bla = Nothing - --- | 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: . --} - -f :: C a => a -> Int - --- | we can export foreign declarations too -foreign import ccall 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 - 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/tests/tests/Test.html.ref b/tests/tests/Test.html.ref deleted file mode 100644 index 3c839612..00000000 --- a/tests/tests/Test.html.ref +++ /dev/null @@ -1,3110 +0,0 @@ - - -Test
 ContentsIndex
Test
Portabilityportable
Stabilityprovisional
Maintainerlibraries@haskell.org
Contents
Type declarations -
Data types -
Records -
Class declarations -
Function types -
Auxiliary stuff -
A hidden module -
A visible module -
Existential / Universal types -
Type signatures with argument docs -
A section -
A subsection -
Description
This module illustrates & tests most of the features of Haddock. - Testing references from the description: T, f, g, visible. -
Synopsis
data T a b
= A Int (Maybe Float)
| B (T a b, T Int Float)
data T2 a b
data T3 a b
= A1 a
| B1 b
data T4 a b
= A2 a
| B2 b
data T5 a b
= A3 a
| B3 b
data T6
= A4
| B4
| C4
newtype N1 a = N1 a
newtype N2 a b = N2 {
n :: a b
}
newtype N3 a b = N3 {
n3 :: a b
}
data N4 a b
newtype N5 a b = N5 {
n5 :: a b
}
newtype N6 a b = N6 {
n6 :: a b
}
newtype N7 a b = N7 {
n7 :: a b
}
data R
= C1 {
p :: Int
q :: forall a. a -> a
r :: Int
s :: Int
}
| C2 {
t :: T1 -> T2 Int Int -> T3 Bool Bool -> T4 Float Float -> T5 () ()
u :: Int
v :: Int
}
data R1 = C3 {
s1 :: Int
s2 :: Int
s3 :: Int
}
class D a => C a where
a :: IO a
b :: [a]
class D a where
d :: T a b
e :: (a, a)
class E a
class F a where
ff :: a
f :: C a => a -> Int
g :: Int -> IO CInt
hidden :: Int -> Int
module Visible
data Ex a
= forall b . C b => Ex1 b
| forall b . Ex2 b
| forall b . C a => Ex3 b
| Ex4 (forall a. a -> a)
k :: T () () -> T2 Int Int -> (T3 Bool Bool -> T4 Float Float) -> T5 () () -> IO ()
l :: (Int, Int, Float) -> Int
m :: R -> N1 () -> IO Int
o :: Float -> IO Float
f' :: Int
Type declarations -
Data types -
data T a b
This comment applies to the following declaration - and it continues until the next non-comment line -
Constructors
A Int (Maybe Float)This comment describes the A constructor -
B (T a b, T Int Float)This comment describes the B constructor -
data T2 a b
An abstract data declaration -
data T3 a b
A data declaration with no documentation annotations on the constructors -
Constructors
A1 a
B1 b
data T4 a b
Constructors
A2 a
B2 b
data T5 a b
Constructors
A3 adocuments A3 -
B3 bdocuments B3 -
data T6
Testing alternative comment styles -
Constructors
A4This is the doc for A4 -
B4This is the doc for B4 -
C4This is the doc for C4 -
newtype N1 a
A newtype -
Constructors
N1 a
newtype N2 a b
A newtype with a fieldname -
Constructors
N2
n :: a b
newtype N3 a b
A newtype with a fieldname, documentation on the field -
Constructors
N3
n3 :: a bthis is the n3 field -
data N4 a b
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 N5 a b
Constructors
N5
n5 :: a bno docs on the datatype or the constructor -
newtype N6 a b
Constructors
N6docs on the constructor only -
n6 :: a b
newtype N7 a b
docs on the newtype and the constructor -
Constructors
N7The N7 constructor -
n7 :: a b
Records -
data R
This is the documentation for the R record, which has four fields, - p, q, r, and s. -
Constructors
C1This is the C1 record constructor, with the following fields: -
p :: IntThis comment applies to the p field -
q :: forall a. a -> aThis comment applies to the q field -
r :: IntThis comment applies to both r and s -
s :: IntThis comment applies to both r and s -
C2This is the C2 record constructor, also with some fields: -
t :: T1 -> T2 Int Int -> T3 Bool Bool -> T4 Float Float -> T5 () ()
u :: Int
v :: Int
data R1
Testing different record commenting styles -
Constructors
C3This is the C3 record constructor -
s1 :: IntThe s1 record selector -
s2 :: IntThe s2 record selector -
s3 :: IntThe s3 record selector -
test that we can export record selectors on their own: -
Class declarations -
class D a => C a where
This comment applies to the previous declaration (the C class) -
Methods
a :: IO a
this is a description of the a method -
b :: [a]
this is a description of the b method -
class D a where
This is a class declaration with no separate docs for the methods -
Methods
d :: T a b
e :: (a, a)
show/hide Instances
class E a
This is a class declaration with no methods (or no methods exported) -
class F a where
Methods
ff :: a
Test that we can export a class method on its own: -
Function types -
f :: C a => a -> Int

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/. -

g :: Int -> IO CInt
we can export foreign declarations too -
Auxiliary stuff -

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
This is some documentation that is attached to a name ($aux2) -
 code block on its own in named doc
 code block on its own in named doc (after newline)

a nested, named doc comment -

with a paragraph, -

 and a code block
test
-test1
-
 test2
-  test3
-
-test1
-test2
-
test3
-test4
-
-test1
-test2
-
test3
-test4
-
test3
-test4
-
-test1
-test2
-

aux11: -

test3
-test4
-
-test1
-test2
-
 foo
-
 bar
-

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 -
hidden :: Int -> Int
A visible module -
module Visible
nested-style doc comments -
Existential / Universal types -
data Ex a
A data-type using existential/universal types -
Constructors
forall b . C b => Ex1 b
forall b . Ex2 b
forall b . C a => Ex3 b
Ex4 (forall a. a -> a)
Type signatures with argument docs -
k
:: T () ()This argument has type T -
-> T2 Int IntThis 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 is a function with documentation for each argument -
l
:: (Int, Int, Float)takes a triple -
-> Intreturns an Int -
m
:: R
-> N1 ()one of the arguments -
-> IO Intand the return value -
This function has some arg docs -
o
:: FloatThe input float -
-> IO FloatThe output float -
A foreign import with argument docs -
A section -
A subsection -
 a literal line
-

$ a non literal line $ -

f' :: Int
a function with a prime can be referred to as f' - but f' doesn't get link'd 'f\'' -
Produced by Haddock version 2.7.2
diff --git a/tests/tests/Ticket112.hs b/tests/tests/Ticket112.hs deleted file mode 100644 index c9cd5117..00000000 --- a/tests/tests/Ticket112.hs +++ /dev/null @@ -1,9 +0,0 @@ -{-# LANGUAGE MagicHash #-} - -module Ticket112 where - -import GHC.Prim - --- | ...given a raw 'Addr#' to the string, and the length of the string. -f :: a -f = undefined diff --git a/tests/tests/Ticket112.html.ref b/tests/tests/Ticket112.html.ref deleted file mode 100644 index 9ff3a192..00000000 --- a/tests/tests/Ticket112.html.ref +++ /dev/null @@ -1,116 +0,0 @@ - - -Ticket112
 ContentsIndex
Ticket112
Synopsis
f :: a
Documentation
f :: a
...given a raw Addr# to the string, and the length of the string. -
Produced by Haddock version 2.7.2
diff --git a/tests/tests/Ticket61.hs b/tests/tests/Ticket61.hs deleted file mode 100644 index 26ca287f..00000000 --- a/tests/tests/Ticket61.hs +++ /dev/null @@ -1,3 +0,0 @@ -module Ticket61 (module Ticket61_Hidden) where - -import Ticket61_Hidden diff --git a/tests/tests/Ticket61.html.ref b/tests/tests/Ticket61.html.ref deleted file mode 100644 index 7931bbf8..00000000 --- a/tests/tests/Ticket61.html.ref +++ /dev/null @@ -1,128 +0,0 @@ - - -Ticket61
 ContentsIndex
Ticket61
Documentation
class C a where
Methods
f :: a
A comment about f -
Produced by Haddock version 2.7.2
diff --git a/tests/tests/Ticket61_Hidden.hs b/tests/tests/Ticket61_Hidden.hs deleted file mode 100644 index 583c10cd..00000000 --- a/tests/tests/Ticket61_Hidden.hs +++ /dev/null @@ -1,7 +0,0 @@ -{-# OPTIONS_HADDOCK hide #-} - -module Ticket61_Hidden where - -class C a where - -- | A comment about f - f :: a diff --git a/tests/tests/Ticket75.hs b/tests/tests/Ticket75.hs deleted file mode 100644 index 94a2f115..00000000 --- a/tests/tests/Ticket75.hs +++ /dev/null @@ -1,7 +0,0 @@ -module Ticket75 where - -data a :- b = Q - --- | A reference to ':-' -f :: Int -f = undefined diff --git a/tests/tests/Ticket75.html.ref b/tests/tests/Ticket75.html.ref deleted file mode 100644 index 1490c1dc..00000000 --- a/tests/tests/Ticket75.html.ref +++ /dev/null @@ -1,174 +0,0 @@ - - -Ticket75
 ContentsIndex
Ticket75
Synopsis
data a :- b = Q
f :: Int
Documentation
data a :- b
Constructors
Q
f :: Int
A reference to :- -
Produced by Haddock version 2.7.2
diff --git a/tests/tests/TypeFamilies.hs b/tests/tests/TypeFamilies.hs deleted file mode 100644 index 561f95fd..00000000 --- a/tests/tests/TypeFamilies.hs +++ /dev/null @@ -1,28 +0,0 @@ -{-# LANGUAGE TypeFamilies #-} - -module TypeFamilies where - --- | Type family G -type family G a :: * - --- | A class with an associated type -class A a where - -- | An associated type - data B a :: * -> * - -- | A method - f :: B a Int - --- | Doc for family -type family F a - - --- | Doc for G Int -type instance G Int = Bool -type instance G Float = Int - - -instance A Int where - data B Int x = Con x - f = Con 3 - -g = Con 5 diff --git a/tests/tests/TypeFamilies.html.ref b/tests/tests/TypeFamilies.html.ref deleted file mode 100644 index 101c5c80..00000000 --- a/tests/tests/TypeFamilies.html.ref +++ /dev/null @@ -1,316 +0,0 @@ - - -TypeFamilies
 ContentsIndex
TypeFamilies
Synopsis
type family G a :: *
class A a where
data B a :: * -> *
f :: B a Int
type family F a
Documentation
type family G a :: *
Type family G -
class A a where
A class with an associated type -
Associated Types
data B a :: * -> *
An associated type -
Methods
f :: B a Int
A method -
show/hide Instances
type family F a
Doc for family -
Produced by Haddock version 2.7.2
diff --git a/tests/tests/TypeOperators.hs b/tests/tests/TypeOperators.hs deleted file mode 100644 index aa0fbe8c..00000000 --- a/tests/tests/TypeOperators.hs +++ /dev/null @@ -1,22 +0,0 @@ -module TypeOperators ( - -- * stuff - (:-:), - (:+:), - Op, - O(..), - biO, - Flip(..) -) where - -data a :-: b - -data (a :+: b) c - -data a `Op` b - -newtype (g `O` f) a = O { unO :: g (f a) } - -biO :: (g `O` f) a -biO = undefined - -newtype Flip (~>) b a = Flip { unFlip :: a ~> b } diff --git a/tests/tests/TypeOperators.html.ref b/tests/tests/TypeOperators.html.ref deleted file mode 100644 index 787737e7..00000000 --- a/tests/tests/TypeOperators.html.ref +++ /dev/null @@ -1,388 +0,0 @@ - - -TypeOperators
 ContentsIndex
TypeOperators
Contents
stuff -
Synopsis
data a :-: b
data (a :+: b) c
data Op a b
newtype O g f a = O {
unO :: g (f a)
}
biO :: (g `O` f) a
newtype Flip (~>) b a = Flip {
unFlip :: a ~> b
}
stuff -
data a :-: b
data (a :+: b) c
data Op a b
newtype O g f a
Constructors
O
unO :: g (f a)
biO :: (g `O` f) a
newtype Flip (~>) b a
Constructors
Flip
unFlip :: a ~> b
Produced by Haddock version 2.7.2
diff --git a/tests/tests/Visible.hs b/tests/tests/Visible.hs deleted file mode 100644 index cad71931..00000000 --- a/tests/tests/Visible.hs +++ /dev/null @@ -1,3 +0,0 @@ -module Visible where -visible :: Int -> Int -visible a = a diff --git a/tests/tests/Visible.html.ref b/tests/tests/Visible.html.ref deleted file mode 100644 index 5a16acb0..00000000 --- a/tests/tests/Visible.html.ref +++ /dev/null @@ -1,91 +0,0 @@ - - -Visible
 ContentsIndex
Visible
Documentation
visible :: Int -> Int
Produced by Haddock version 2.7.2
diff --git a/tests/unit-tests/parsetests.hs b/tests/unit-tests/parsetests.hs new file mode 100644 index 00000000..f66355e2 --- /dev/null +++ b/tests/unit-tests/parsetests.hs @@ -0,0 +1,56 @@ +module Main (main) where + +import Test.HUnit +import RdrName (RdrName) +import DynFlags (defaultDynFlags) +import Haddock.Lex (tokenise) +import Haddock.Parse (parseParas) +import Haddock.Types + +instance Show RdrName where + show x = "RdrName" + +data ParseTest = ParseTest { + input :: String + , result :: (Maybe (Doc RdrName)) + } + +tests :: [ParseTest] +tests = [ + ParseTest { + input = "foobar" + , result = Just $ DocParagraph $ DocString "foobar\n" + } + + , ParseTest { + input = "foobar\n\nghci> fib 10\n55" + , result = Just $ DocAppend (DocParagraph $ DocString "foobar\n") (DocExamples $ [Example "fib 10" ["55"]]) + } + + , ParseTest { + input = "foobar\nghci> fib 10\n55" + , result = Nothing -- parse error + } + + , ParseTest { + input = "foobar\n\n> some code" + , result = Just (DocAppend (DocParagraph (DocString "foobar\n")) (DocCodeBlock (DocString " some code\n"))) + } + + , ParseTest { + input = "foobar\n> some code" + , result = Nothing -- parse error + } + ] + + +main = do + _ <- runTestTT $ TestList $ map testFromParseTest tests + return (); + where + + testFromParseTest :: ParseTest -> Test + testFromParseTest (ParseTest input result) = TestCase $ assertEqual input (parse input) result + + parse :: String -> Maybe (Doc RdrName) + parse input = parseParas $ tokenise defaultDynFlags input (0,0) diff --git a/tests/unit-tests/runparsetests.sh b/tests/unit-tests/runparsetests.sh new file mode 100644 index 00000000..f02d3f1c --- /dev/null +++ b/tests/unit-tests/runparsetests.sh @@ -0,0 +1,14 @@ +#!/bin/sh +cd `dirname $0` + +runhaskell -hide-all-packages -cpp \ + -packagecontainers \ + -packagearray \ + -packagebase \ + -packageghc \ + -packagexhtml \ + -packageghc-paths \ + -packageHUnit \ + -i../dist/build/ \ + -i../src/ \ + parsetests.hs -- cgit v1.2.3