diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2023-01-07 16:25:13 +0000 |
---|---|---|
committer | Alan Zimmerman <alan.zimm@gmail.com> | 2023-01-07 16:29:41 +0000 |
commit | 9f18df76f6e61b72205eb40b97f8debc2949b831 (patch) | |
tree | 3a1081302b84f07994e798013b3390546cb1d60e | |
parent | 2459c3587bfe8105c628f9733bf32d1d3c903375 (diff) | |
download | haskell-wip/az/epa-hsdocty.tar.gz |
EPA: exact print HsDocTywip/az/epa-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 |