aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/html-tests/tests/Hyperlinks.hs8
-rw-r--r--tests/html-tests/tests/Hyperlinks.html.ref89
-rw-r--r--tests/html-tests/tests/mini_Hyperlinks.html.ref31
-rw-r--r--tests/unit-tests/.ghci2
-rw-r--r--tests/unit-tests/parsetests.hs14
5 files changed, 143 insertions, 1 deletions
diff --git a/tests/html-tests/tests/Hyperlinks.hs b/tests/html-tests/tests/Hyperlinks.hs
new file mode 100644
index 00000000..34e64448
--- /dev/null
+++ b/tests/html-tests/tests/Hyperlinks.hs
@@ -0,0 +1,8 @@
+module Hyperlinks where
+
+-- |
+-- A plain URL: <http://example.com/>
+--
+-- A URL with a label: <http://example.com/ some link>
+foo :: Int
+foo = 23
diff --git a/tests/html-tests/tests/Hyperlinks.html.ref b/tests/html-tests/tests/Hyperlinks.html.ref
new file mode 100644
index 00000000..59ec6c26
--- /dev/null
+++ b/tests/html-tests/tests/Hyperlinks.html.ref
@@ -0,0 +1,89 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+ ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+ /><title
+ >Hyperlinks</title
+ ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+ /><script src="haddock-util.js" type="text/javascript"
+ ></script
+ ><script type="text/javascript"
+ >//<![CDATA[
+window.onload = function () {pageLoad();setSynopsis("mini_Hyperlinks.html");};
+//]]>
+</script
+ ></head
+ ><body
+ ><div id="package-header"
+ ><ul class="links" id="page-menu"
+ ><li
+ ><a href=""
+ >Contents</a
+ ></li
+ ><li
+ ><a href=""
+ >Index</a
+ ></li
+ ></ul
+ ><p class="caption empty"
+ >&nbsp;</p
+ ></div
+ ><div id="content"
+ ><div id="module-header"
+ ><table class="info"
+ ><tr
+ ><th
+ >Safe Haskell</th
+ ><td
+ >None</td
+ ></tr
+ ></table
+ ><p class="caption"
+ >Hyperlinks</p
+ ></div
+ ><div id="synopsis"
+ ><p id="control.syn" class="caption expander" onclick="toggleSection('syn')"
+ >Synopsis</p
+ ><ul id="section.syn" class="hide" onclick="toggleSection('syn')"
+ ><li class="src short"
+ ><a href=""
+ >foo</a
+ > :: <a href=""
+ >Int</a
+ ></li
+ ></ul
+ ></div
+ ><div id="interface"
+ ><h1
+ >Documentation</h1
+ ><div class="top"
+ ><p class="src"
+ ><a name="v:foo" class="def"
+ >foo</a
+ > :: <a href=""
+ >Int</a
+ ></p
+ ><div class="doc"
+ ><p
+ >A plain URL: <a href=""
+ >http://example.com/</a
+ >
+</p
+ ><p
+ >A URL with a label: <a href=""
+ >some link</a
+ >
+</p
+ ></div
+ ></div
+ ></div
+ ></div
+ ><div id="footer"
+ ><p
+ >Produced by <a href=""
+ >Haddock</a
+ > version 2.10.0</p
+ ></div
+ ></body
+ ></html
+>
diff --git a/tests/html-tests/tests/mini_Hyperlinks.html.ref b/tests/html-tests/tests/mini_Hyperlinks.html.ref
new file mode 100644
index 00000000..f0c7d65a
--- /dev/null
+++ b/tests/html-tests/tests/mini_Hyperlinks.html.ref
@@ -0,0 +1,31 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+><head
+ ><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
+ /><title
+ >Hyperlinks</title
+ ><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean"
+ /><script src="haddock-util.js" type="text/javascript"
+ ></script
+ ><script type="text/javascript"
+ >//<![CDATA[
+window.onload = function () {pageLoad();};
+//]]>
+</script
+ ></head
+ ><body id="mini"
+ ><div id="module-header"
+ ><p class="caption"
+ >Hyperlinks</p
+ ></div
+ ><div id="interface"
+ ><div class="top"
+ ><p class="src"
+ ><a href="" target="main"
+ >foo</a
+ ></p
+ ></div
+ ></div
+ ></body
+ ></html
+>
diff --git a/tests/unit-tests/.ghci b/tests/unit-tests/.ghci
index 10563664..dcc5b13d 100644
--- a/tests/unit-tests/.ghci
+++ b/tests/unit-tests/.ghci
@@ -1 +1 @@
-:set -i../../src -i../../dist/build/autogen -i../../dist/build/haddock/haddock-tmp/ -packageghc -optP-include -optP../../dist/build/autogen/cabal_macros.h -XCPP -XDeriveDataTypeable -XScopedTypeVariables -XMagicHash
+:set -i../../src -i../../dist/build/autogen -i../../dist/build/haddock/haddock-tmp/ -packageghc -optP-include -optP../../dist/build/autogen/cabal_macros.h
diff --git a/tests/unit-tests/parsetests.hs b/tests/unit-tests/parsetests.hs
index 7180a79e..0192ebfc 100644
--- a/tests/unit-tests/parsetests.hs
+++ b/tests/unit-tests/parsetests.hs
@@ -9,6 +9,7 @@ import Haddock.Lex (tokenise)
import Haddock.Parse (parseParas)
import Haddock.Types
import Outputable
+import Data.Monoid
instance Outputable a => Show a where
show = showSDoc . ppr
@@ -53,8 +54,21 @@ tests = [
input = ">>> putFooBar\nfoo\n<BLANKLINE>\nbar"
, result = Just $ DocExamples $ [Example "putFooBar" ["foo","","bar"]]
}
+
+ -- tests for links
+ , ParseTest {
+ input = "<http://example.com/>"
+ , result = Just . DocParagraph $ hyperlink "http://example.com/" Nothing `mappend` DocString "\n"
+ }
+
+ , ParseTest {
+ input = "<http://example.com/ some link>"
+ , result = Just . DocParagraph $ hyperlink "http://example.com/" (Just "some link") `mappend` DocString "\n"
+ }
]
+hyperlink :: String -> Maybe String -> Doc RdrName
+hyperlink url = DocHyperlink . Hyperlink url
main :: IO ()
main = do