diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2023-01-07 16:25:13 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-01-09 02:36:20 -0500 |
commit | 965a273510adfac4f041a31182c2fec82e614e47 (patch) | |
tree | 2ce9b1e9b2671a058f22fc6b070908d75035e812 | |
parent | 365b30453f0f7361edd40d32ebaa4bea784f3a2b (diff) | |
download | haskell-965a273510adfac4f041a31182c2fec82e614e47.tar.gz |
EPA: exact print HsDocTy
To match ghc-exactprint
https://github.com/alanz/ghc-exactprint/pull/121
-rw-r--r-- | testsuite/tests/printer/HsDocTy.hs | 6 | ||||
-rw-r--r-- | testsuite/tests/printer/Makefile | 6 | ||||
-rw-r--r-- | testsuite/tests/printer/all.T | 3 | ||||
-rw-r--r-- | utils/check-exact/ExactPrint.hs | 4 | ||||
-rw-r--r-- | utils/check-exact/Main.hs | 3 |
5 files changed, 20 insertions, 2 deletions
diff --git a/testsuite/tests/printer/HsDocTy.hs b/testsuite/tests/printer/HsDocTy.hs new file mode 100644 index 0000000000..7bcd985ed8 --- /dev/null +++ b/testsuite/tests/printer/HsDocTy.hs @@ -0,0 +1,6 @@ +{-# OPTIONS_GHC -haddock #-} +module HsDocTy where + +class C1 a where + f1 :: a -> Int + -- ^ comment on Int diff --git a/testsuite/tests/printer/Makefile b/testsuite/tests/printer/Makefile index ca29268693..e98cfc425c 100644 --- a/testsuite/tests/printer/Makefile +++ b/testsuite/tests/printer/Makefile @@ -769,3 +769,9 @@ Test21355: Test21805: $(CHECK_PPR) $(LIBDIR) Test21805.hs $(CHECK_EXACT) $(LIBDIR) Test21805.hs + +.PHONY: HsDocTy +HsDocTy: + # See comment on pprWithDocString, this won't round trip + # $(CHECK_PPR) $(LIBDIR) HsDocTy.hs + $(CHECK_EXACT) $(LIBDIR) HsDocTy.hs diff --git a/testsuite/tests/printer/all.T b/testsuite/tests/printer/all.T index 620c92d5ba..050031c6a3 100644 --- a/testsuite/tests/printer/all.T +++ b/testsuite/tests/printer/all.T @@ -185,4 +185,5 @@ test('Test21805', [ignore_stderr, req_ppr_deps], makefile_test, ['Test21805']) test('T22488', normal, ghci_script, ['T22488.script']) test('T22488_docHead', normal, compile_and_run, ['-package ghc']) test('T20531', extra_files(['T20531_defs.hs']), ghci_script, ['T20531.script']) -test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script'])
\ No newline at end of file +test('T20531_red_ticks', extra_files(['T20531_defs.hs']), ghci_script, ['T20531_red_ticks.script']) +test('HsDocTy', [ignore_stderr, req_ppr_deps], makefile_test, ['HsDocTy'])
\ No newline at end of file diff --git a/utils/check-exact/ExactPrint.hs b/utils/check-exact/ExactPrint.hs index 30a3234ee0..df7fdfda1e 100644 --- a/utils/check-exact/ExactPrint.hs +++ b/utils/check-exact/ExactPrint.hs @@ -3898,6 +3898,10 @@ instance ExactPrint (HsType GhcPs) where exact (HsSpliceTy a splice) = do splice' <- markAnnotated splice return (HsSpliceTy a splice') + exact (HsDocTy an ty doc) = do + ty' <- markAnnotated ty + doc' <- markAnnotated doc + return (HsDocTy an ty' doc') exact (HsBangTy an (HsSrcBang mt up str) ty) = do an0 <- case mt of diff --git a/utils/check-exact/Main.hs b/utils/check-exact/Main.hs index f286355cc1..ab12ac4c09 100644 --- a/utils/check-exact/Main.hs +++ b/utils/check-exact/Main.hs @@ -59,7 +59,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../testsuite/tests/ghc-api/exactprint/AddDecl2.hs" (Just changeAddDecl2) -- "../../testsuite/tests/ghc-api/exactprint/AddDecl3.hs" (Just changeAddDecl3) -- "../../testsuite/tests/ghc-api/exactprint/LocalDecls.hs" (Just changeLocalDecls) - "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) + -- "../../testsuite/tests/ghc-api/exactprint/LocalDecls2.hs" (Just changeLocalDecls2) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3a.hs" (Just changeWhereIn3a) -- "../../testsuite/tests/ghc-api/exactprint/WhereIn3b.hs" (Just changeWhereIn3b) -- "../../testsuite/tests/ghc-api/exactprint/AddLocalDecl1.hs" (Just addLocaLDecl1) @@ -203,6 +203,7 @@ _tt = testOneFile changers "/home/alanz/mysrc/git.haskell.org/worktree/master/_b -- "../../testsuite/tests/ghc-api/exactprint/Test20239.hs" Nothing -- "../../testsuite/tests/printer/PprArrowLambdaCase.hs" Nothing -- "../../testsuite/tests/printer/Test16279.hs" Nothing + "../../testsuite/tests/printer/HsDocTy.hs" Nothing -- cloneT does not need a test, function can be retired |