summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorThomas Miedema <thomasmiedema@gmail.com>2016-02-25 15:51:38 +0100
committerBen Gamari <ben@smart-cactus.org>2016-02-25 17:18:27 +0100
commit6350eb1126e29b93829de688623c91b772f6d9eb (patch)
tree64a4f107929e4d46621d3fc57013008dbcada6bb /testsuite/tests
parent67393977489942ef41f4f7d4a77076c15db18b92 (diff)
downloadhaskell-6350eb1126e29b93829de688623c91b772f6d9eb.tar.gz
Handle multiline named haddock comments properly
Fixes #10398 in a different way, thereby also fixing #11579. I inverted the logic of the Bool argument to "worker", to hopefully make it more self-explanatory. Reviewers: austin, hvr, bgamari Reviewed By: bgamari Differential Revision: https://phabricator.haskell.org/D1935
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/ghc-api/T11579.hs26
-rw-r--r--testsuite/tests/ghc-api/T11579.stdout1
-rw-r--r--testsuite/tests/ghc-api/all.T2
3 files changed, 29 insertions, 0 deletions
diff --git a/testsuite/tests/ghc-api/T11579.hs b/testsuite/tests/ghc-api/T11579.hs
new file mode 100644
index 0000000000..3294f999f2
--- /dev/null
+++ b/testsuite/tests/ghc-api/T11579.hs
@@ -0,0 +1,26 @@
+import System.Environment
+import DynFlags
+import FastString
+import GHC
+import StringBuffer
+import Lexer
+import SrcLoc
+
+main :: IO ()
+main = do
+ [libdir] <- getArgs
+
+ let stringBuffer = stringToStringBuffer "-- $bar some\n-- named chunk"
+ loc = mkRealSrcLoc (mkFastString "Foo.hs") 1 1
+
+ token <- runGhc (Just libdir) $ do
+ dflags <- getSessionDynFlags
+ let pstate = mkPState (dflags `gopt_set` Opt_Haddock) stringBuffer loc
+ case unP (lexer False return) pstate of
+ POk _ token -> return (unLoc token)
+ _ -> error "No token"
+
+ -- #11579
+ -- Expected: "ITdocCommentNamed "bar some\n named chunk"
+ -- Actual (with ghc-8.0.1-rc2): "ITdocCommentNamed "bar some"
+ print token
diff --git a/testsuite/tests/ghc-api/T11579.stdout b/testsuite/tests/ghc-api/T11579.stdout
new file mode 100644
index 0000000000..7603e535e7
--- /dev/null
+++ b/testsuite/tests/ghc-api/T11579.stdout
@@ -0,0 +1 @@
+ITdocCommentNamed "bar some\n named chunk"
diff --git a/testsuite/tests/ghc-api/all.T b/testsuite/tests/ghc-api/all.T
index 8aa2ede97f..3859d538c5 100644
--- a/testsuite/tests/ghc-api/all.T
+++ b/testsuite/tests/ghc-api/all.T
@@ -21,3 +21,5 @@ test('T10942', extra_run_opts('"' + config.libdir + '"'),
test('T9015', extra_run_opts('"' + config.libdir + '"'),
compile_and_run,
['-package ghc'])
+test('T11579', extra_run_opts('"' + config.libdir + '"'), compile_and_run,
+ ['-package ghc'])