summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakenobu Tani <takenobu.hs@gmail.com>2019-09-28 14:02:01 +0900
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-09-30 22:42:53 -0400
commitb36dd49b6ce14c6d7781518091fd0d98d5730899 (patch)
tree4f4fadfe5101e3d19f975fc94aa4a358cce5a849
parent6f8550a3af45467c37367626dc99c911d3a3d4d1 (diff)
downloadhaskell-b36dd49b6ce14c6d7781518091fd0d98d5730899.tar.gz
testsuite: Add minimal test for :doc command
Currently, there are no testcases for GHCi `:doc` command. Perhaps because it was experimental. And it could be changed in the future. But `:doc` command is already useful, so I add a minimal regression test to keep current behavior. See also 85309a3cda for implementation of `:doc` command.
-rwxr-xr-xtestsuite/tests/ghci/scripts/all.T1
-rw-r--r--testsuite/tests/ghci/scripts/ghci065.hs28
-rw-r--r--testsuite/tests/ghci/scripts/ghci065.script11
-rw-r--r--testsuite/tests/ghci/scripts/ghci065.stdout7
4 files changed, 47 insertions, 0 deletions
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 9ba975172c..dedca954f2 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -107,6 +107,7 @@ test('ghci062', [extra_files(['ghci062/', 'ghci062/Test.hs']),
ghci_script, ['ghci062.script'])
test('ghci063', normal, ghci_script, ['ghci063.script'])
test('ghci064', normal, ghci_script, ['ghci064.script'])
+test('ghci065', [extra_hc_opts("-haddock")], ghci_script, ['ghci065.script'])
test('T2452', [extra_hc_opts("-fno-implicit-import-qualified")],
ghci_script, ['T2452.script'])
test('T2766', normal, ghci_script, ['T2766.script'])
diff --git a/testsuite/tests/ghci/scripts/ghci065.hs b/testsuite/tests/ghci/scripts/ghci065.hs
new file mode 100644
index 0000000000..7035b4815d
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/ghci065.hs
@@ -0,0 +1,28 @@
+--
+-- This is a minimal test for :doc command.
+--
+-- To avoid depending haddock's pretty-printing,
+-- this test is constructed with simple text (without markup) only.
+--
+
+module Test where
+
+-- | This is the haddock comment of a data declaration for Data1.
+data Data1 = Val1a | Val1b
+
+data Data2 = Val2a -- ^ This is the haddock comment of a data value for Val2a
+ | Val2b -- ^ This is the haddock comment of a data value for Val2b
+
+
+-- | This is the haddock comment of a function declaration for func1.
+func1 :: Int -> Int -> Int
+func1 x y = x + y
+
+-- This is NOT a haddock comment.
+func2 :: Int -> Int -> Int
+func2 x y = x + y
+
+-- | This is the haddock comment of a function declaration for func3.
+-- Here's multiple line comment for func3.
+func3 :: Int -> Int -> Int
+func3 x y = x + y
diff --git a/testsuite/tests/ghci/scripts/ghci065.script b/testsuite/tests/ghci/scripts/ghci065.script
new file mode 100644
index 0000000000..ec51b24fe5
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/ghci065.script
@@ -0,0 +1,11 @@
+-- Testing :doc command simply
+
+:load ghci065
+
+:doc Data1
+:doc Val2a
+:doc Val2b
+
+:doc func1
+:doc func2
+:doc func3
diff --git a/testsuite/tests/ghci/scripts/ghci065.stdout b/testsuite/tests/ghci/scripts/ghci065.stdout
new file mode 100644
index 0000000000..c3d69ca4ef
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/ghci065.stdout
@@ -0,0 +1,7 @@
+ This is the haddock comment of a data declaration for Data1.
+ This is the haddock comment of a data value for Val2a
+ This is the haddock comment of a data value for Val2b
+ This is the haddock comment of a function declaration for func1.
+<has no documentation>
+ This is the haddock comment of a function declaration for func3.
+ Here's multiple line comment for func3.