From 1c56e0e6c22600ff99be401af0f94d82f5b1c662 Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 23 Dec 2020 08:33:24 +0100 Subject: [PATCH] Test apply-refact preserve comments --- test/functional/FunctionalCodeAction.hs | 11 +++++++++++ test/testdata/hlint/ApplyRefact6.hs | 11 +++++++++++ test/testdata/hlint/hie.yaml | 1 + 3 files changed, 23 insertions(+) create mode 100644 test/testdata/hlint/ApplyRefact6.hs diff --git a/test/functional/FunctionalCodeAction.hs b/test/functional/FunctionalCodeAction.hs index 8b0dce7525..a4cdadba0c 100644 --- a/test/functional/FunctionalCodeAction.hs +++ b/test/functional/FunctionalCodeAction.hs @@ -155,6 +155,9 @@ hlintTests = testGroup "hlint suggestions" [ testCase "hlint diagnostics ignore hints honouring HLINT annotations" $ runHlintSession "" $ do doc <- openDoc "ApplyRefact5.hs" "haskell" expectNoMoreDiagnostics 3 doc "hlint" + + , testCase "apply-refact preserve regular comments" $ runHlintSession "" $ do + testRefactor "ApplyRefact6.hs" "Redundant bracket" expectedComments ] where runHlintSession :: FilePath -> Session a -> IO a @@ -193,6 +196,14 @@ hlintTests = testGroup "hlint suggestions" [ , "g = 2" , "#endif", "" ] + expectedComments = [ "-- comment before header" + , "module ApplyRefact6 where", "" + , "{-# standalone annotation #-}", "" + , "-- standalone comment", "" + , "-- | haddock comment" + , "f = {- inline comment -} 1 -- ending comment", "" + , "-- final comment" + ] renameTests :: TestTree renameTests = testGroup "rename suggestions" [ diff --git a/test/testdata/hlint/ApplyRefact6.hs b/test/testdata/hlint/ApplyRefact6.hs new file mode 100644 index 0000000000..c0d0d379ba --- /dev/null +++ b/test/testdata/hlint/ApplyRefact6.hs @@ -0,0 +1,11 @@ +-- comment before header +module ApplyRefact6 where + +{-# standalone annotation #-} + +-- standalone comment + +-- | haddock comment +f = {- inline comment -} (1) -- ending comment + +-- final comment diff --git a/test/testdata/hlint/hie.yaml b/test/testdata/hlint/hie.yaml index 08c71a6ee2..98942ebb69 100644 --- a/test/testdata/hlint/hie.yaml +++ b/test/testdata/hlint/hie.yaml @@ -8,3 +8,4 @@ cradle: - "ApplyRefact3" - "ApplyRefact4" - "ApplyRefact5" + - "ApplyRefact6"