From 1f0d31f2c438e3a0014b04eeef2be9e0890425d2 Mon Sep 17 00:00:00 2001 From: nini-faroux Date: Wed, 1 Dec 2021 12:49:34 +0000 Subject: [PATCH] Add known broken tests for import placement --- .../MultiLinePragma.expected.hs | 13 ++ .../data/import-placement/MultiLinePragma.hs | 12 + .../OptionsNotAtTopWithSpaces.expected.hs | 16 ++ .../OptionsNotAtTopWithSpaces.hs | 15 ++ .../OptionsPragmaNotAtTop.expected.hs | 8 + .../import-placement/OptionsPragmaNotAtTop.hs | 7 + ...PragmaNotAtTopMultipleComments.expected.hs | 23 ++ .../PragmaNotAtTopMultipleComments.hs | 22 ++ ...ragmaNotAtTopWithCommentsAtTop.expected.hs | 18 ++ .../PragmaNotAtTopWithCommentsAtTop.hs | 17 ++ .../PragmaNotAtTopWithImports.expected.hs | 19 ++ .../PragmaNotAtTopWithImports.hs | 18 ++ .../PragmaNotAtTopWithModuleDecl.expected.hs | 22 ++ .../PragmaNotAtTopWithModuleDecl.hs | 21 ++ .../ShebangNotAtTop.expected.hs | 10 + .../data/import-placement/ShebangNotAtTop.hs | 9 + .../ShebangNotAtTopNoSpace.expected.hs | 8 + .../ShebangNotAtTopNoSpace.hs | 7 + .../ShebangNotAtTopWithSpaces.expected.hs | 21 ++ .../ShebangNotAtTopWithSpaces.hs | 20 ++ .../WhereDeclLowerInFile.expected.hs | 18 ++ .../import-placement/WhereDeclLowerInFile.hs | 17 ++ ...ereKeywordLowerInFileNoExports.expected.hs | 16 ++ .../WhereKeywordLowerInFileNoExports.hs | 15 ++ ghcide/test/exe/Main.hs | 219 ++++++++++++++++-- 25 files changed, 569 insertions(+), 22 deletions(-) create mode 100644 ghcide/test/data/import-placement/MultiLinePragma.expected.hs create mode 100644 ghcide/test/data/import-placement/MultiLinePragma.hs create mode 100644 ghcide/test/data/import-placement/OptionsNotAtTopWithSpaces.expected.hs create mode 100644 ghcide/test/data/import-placement/OptionsNotAtTopWithSpaces.hs create mode 100644 ghcide/test/data/import-placement/OptionsPragmaNotAtTop.expected.hs create mode 100644 ghcide/test/data/import-placement/OptionsPragmaNotAtTop.hs create mode 100644 ghcide/test/data/import-placement/PragmaNotAtTopMultipleComments.expected.hs create mode 100644 ghcide/test/data/import-placement/PragmaNotAtTopMultipleComments.hs create mode 100644 ghcide/test/data/import-placement/PragmaNotAtTopWithCommentsAtTop.expected.hs create mode 100644 ghcide/test/data/import-placement/PragmaNotAtTopWithCommentsAtTop.hs create mode 100644 ghcide/test/data/import-placement/PragmaNotAtTopWithImports.expected.hs create mode 100644 ghcide/test/data/import-placement/PragmaNotAtTopWithImports.hs create mode 100644 ghcide/test/data/import-placement/PragmaNotAtTopWithModuleDecl.expected.hs create mode 100644 ghcide/test/data/import-placement/PragmaNotAtTopWithModuleDecl.hs create mode 100644 ghcide/test/data/import-placement/ShebangNotAtTop.expected.hs create mode 100644 ghcide/test/data/import-placement/ShebangNotAtTop.hs create mode 100644 ghcide/test/data/import-placement/ShebangNotAtTopNoSpace.expected.hs create mode 100644 ghcide/test/data/import-placement/ShebangNotAtTopNoSpace.hs create mode 100644 ghcide/test/data/import-placement/ShebangNotAtTopWithSpaces.expected.hs create mode 100644 ghcide/test/data/import-placement/ShebangNotAtTopWithSpaces.hs create mode 100644 ghcide/test/data/import-placement/WhereDeclLowerInFile.expected.hs create mode 100644 ghcide/test/data/import-placement/WhereDeclLowerInFile.hs create mode 100644 ghcide/test/data/import-placement/WhereKeywordLowerInFileNoExports.expected.hs create mode 100644 ghcide/test/data/import-placement/WhereKeywordLowerInFileNoExports.hs diff --git a/ghcide/test/data/import-placement/MultiLinePragma.expected.hs b/ghcide/test/data/import-placement/MultiLinePragma.expected.hs new file mode 100644 index 0000000000..ca0b9f28dc --- /dev/null +++ b/ghcide/test/data/import-placement/MultiLinePragma.expected.hs @@ -0,0 +1,13 @@ +{-# OPTIONS_GHC -Wall #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards, + OverloadedStrings #-} +{-# OPTIONS_GHC -Wall, + -Wno-unused-imports #-} +import Data.Monoid + + +-- some comment +class Semigroup a => SomeData a + +instance SomeData All diff --git a/ghcide/test/data/import-placement/MultiLinePragma.hs b/ghcide/test/data/import-placement/MultiLinePragma.hs new file mode 100644 index 0000000000..e3e6187193 --- /dev/null +++ b/ghcide/test/data/import-placement/MultiLinePragma.hs @@ -0,0 +1,12 @@ +{-# OPTIONS_GHC -Wall #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards, + OverloadedStrings #-} +{-# OPTIONS_GHC -Wall, + -Wno-unused-imports #-} + + +-- some comment +class Semigroup a => SomeData a + +instance SomeData All diff --git a/ghcide/test/data/import-placement/OptionsNotAtTopWithSpaces.expected.hs b/ghcide/test/data/import-placement/OptionsNotAtTopWithSpaces.expected.hs new file mode 100644 index 0000000000..912d6a210c --- /dev/null +++ b/ghcide/test/data/import-placement/OptionsNotAtTopWithSpaces.expected.hs @@ -0,0 +1,16 @@ +{-# LANGUAGE OverloadedStrings #-} + + +{-# LANGUAGE TupleSections #-} +import Data.Monoid + + + + +class Semigroup a => SomeData a +instance SomeData All + +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} + +addOne :: Int -> Int +addOne x = x + 1 diff --git a/ghcide/test/data/import-placement/OptionsNotAtTopWithSpaces.hs b/ghcide/test/data/import-placement/OptionsNotAtTopWithSpaces.hs new file mode 100644 index 0000000000..9b49dacfba --- /dev/null +++ b/ghcide/test/data/import-placement/OptionsNotAtTopWithSpaces.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE OverloadedStrings #-} + + +{-# LANGUAGE TupleSections #-} + + + + +class Semigroup a => SomeData a +instance SomeData All + +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} + +addOne :: Int -> Int +addOne x = x + 1 diff --git a/ghcide/test/data/import-placement/OptionsPragmaNotAtTop.expected.hs b/ghcide/test/data/import-placement/OptionsPragmaNotAtTop.expected.hs new file mode 100644 index 0000000000..55a6c60dbb --- /dev/null +++ b/ghcide/test/data/import-placement/OptionsPragmaNotAtTop.expected.hs @@ -0,0 +1,8 @@ +import Data.Monoid +class Semigroup a => SomeData a +instance SomeData All + +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} + +addOne :: Int -> Int +addOne x = x + 1 diff --git a/ghcide/test/data/import-placement/OptionsPragmaNotAtTop.hs b/ghcide/test/data/import-placement/OptionsPragmaNotAtTop.hs new file mode 100644 index 0000000000..ad7c01f4e7 --- /dev/null +++ b/ghcide/test/data/import-placement/OptionsPragmaNotAtTop.hs @@ -0,0 +1,7 @@ +class Semigroup a => SomeData a +instance SomeData All + +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} + +addOne :: Int -> Int +addOne x = x + 1 diff --git a/ghcide/test/data/import-placement/PragmaNotAtTopMultipleComments.expected.hs b/ghcide/test/data/import-placement/PragmaNotAtTopMultipleComments.expected.hs new file mode 100644 index 0000000000..eead1cb55e --- /dev/null +++ b/ghcide/test/data/import-placement/PragmaNotAtTopMultipleComments.expected.hs @@ -0,0 +1,23 @@ +{-# LANGUAGE OverloadedStrings #-} + +{-# OPTIONS_GHC -Wall, + OPTIONS_GHC -Wno-unrecognised-pragmas #-} +-- another comment +-- oh +{- multi line +comment +-} + +{-# LANGUAGE TupleSections #-} +import Data.Monoid +{- some comment -} + +-- again +class Semigroup a => SomeData a +instance SomeData All + +#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])" +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} + +addOne :: Int -> Int +addOne x = x + 1 diff --git a/ghcide/test/data/import-placement/PragmaNotAtTopMultipleComments.hs b/ghcide/test/data/import-placement/PragmaNotAtTopMultipleComments.hs new file mode 100644 index 0000000000..306af5aa71 --- /dev/null +++ b/ghcide/test/data/import-placement/PragmaNotAtTopMultipleComments.hs @@ -0,0 +1,22 @@ +{-# LANGUAGE OverloadedStrings #-} + +{-# OPTIONS_GHC -Wall, + OPTIONS_GHC -Wno-unrecognised-pragmas #-} +-- another comment +-- oh +{- multi line +comment +-} + +{-# LANGUAGE TupleSections #-} +{- some comment -} + +-- again +class Semigroup a => SomeData a +instance SomeData All + +#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])" +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} + +addOne :: Int -> Int +addOne x = x + 1 diff --git a/ghcide/test/data/import-placement/PragmaNotAtTopWithCommentsAtTop.expected.hs b/ghcide/test/data/import-placement/PragmaNotAtTopWithCommentsAtTop.expected.hs new file mode 100644 index 0000000000..57fc1614be --- /dev/null +++ b/ghcide/test/data/import-placement/PragmaNotAtTopWithCommentsAtTop.expected.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE OverloadedStrings #-} + +{-# OPTIONS_GHC -Wall #-} +-- another comment + +{-# LANGUAGE TupleSections #-} +import Data.Monoid +{- some comment -} + + +class Semigroup a => SomeData a +instance SomeData All + +#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])" +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} + +addOne :: Int -> Int +addOne x = x + 1 diff --git a/ghcide/test/data/import-placement/PragmaNotAtTopWithCommentsAtTop.hs b/ghcide/test/data/import-placement/PragmaNotAtTopWithCommentsAtTop.hs new file mode 100644 index 0000000000..c50fe08c85 --- /dev/null +++ b/ghcide/test/data/import-placement/PragmaNotAtTopWithCommentsAtTop.hs @@ -0,0 +1,17 @@ +{-# LANGUAGE OverloadedStrings #-} + +{-# OPTIONS_GHC -Wall #-} +-- another comment + +{-# LANGUAGE TupleSections #-} +{- some comment -} + + +class Semigroup a => SomeData a +instance SomeData All + +#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])" +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} + +addOne :: Int -> Int +addOne x = x + 1 diff --git a/ghcide/test/data/import-placement/PragmaNotAtTopWithImports.expected.hs b/ghcide/test/data/import-placement/PragmaNotAtTopWithImports.expected.hs new file mode 100644 index 0000000000..f2525d60e8 --- /dev/null +++ b/ghcide/test/data/import-placement/PragmaNotAtTopWithImports.expected.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# OPTIONS_GHC -Wall #-} + +{-# LANGUAGE TupleSections #-} +module Test +( SomeData(..) +) where +import Data.Text +import Data.Monoid + + +class Semigroup a => SomeData a +instance SomeData All + +#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])" +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} + +addOne :: Int -> Int +addOne x = x + 1 diff --git a/ghcide/test/data/import-placement/PragmaNotAtTopWithImports.hs b/ghcide/test/data/import-placement/PragmaNotAtTopWithImports.hs new file mode 100644 index 0000000000..849c029069 --- /dev/null +++ b/ghcide/test/data/import-placement/PragmaNotAtTopWithImports.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# OPTIONS_GHC -Wall #-} + +{-# LANGUAGE TupleSections #-} +module Test +( SomeData(..) +) where +import Data.Text + + +class Semigroup a => SomeData a +instance SomeData All + +#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])" +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} + +addOne :: Int -> Int +addOne x = x + 1 diff --git a/ghcide/test/data/import-placement/PragmaNotAtTopWithModuleDecl.expected.hs b/ghcide/test/data/import-placement/PragmaNotAtTopWithModuleDecl.expected.hs new file mode 100644 index 0000000000..d62e2e32f1 --- /dev/null +++ b/ghcide/test/data/import-placement/PragmaNotAtTopWithModuleDecl.expected.hs @@ -0,0 +1,22 @@ +{-# LANGUAGE OverloadedStrings #-} + + +{-# OPTIONS_GHC -Wall #-} + +{-# LANGUAGE TupleSections #-} +module Test +( SomeData(..) +) where +import Data.Monoid + + + + +class Semigroup a => SomeData a +instance SomeData All + +#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])" +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} + +addOne :: Int -> Int +addOne x = x + 1 diff --git a/ghcide/test/data/import-placement/PragmaNotAtTopWithModuleDecl.hs b/ghcide/test/data/import-placement/PragmaNotAtTopWithModuleDecl.hs new file mode 100644 index 0000000000..6115d25973 --- /dev/null +++ b/ghcide/test/data/import-placement/PragmaNotAtTopWithModuleDecl.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE OverloadedStrings #-} + + +{-# OPTIONS_GHC -Wall #-} + +{-# LANGUAGE TupleSections #-} +module Test +( SomeData(..) +) where + + + + +class Semigroup a => SomeData a +instance SomeData All + +#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])" +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} + +addOne :: Int -> Int +addOne x = x + 1 diff --git a/ghcide/test/data/import-placement/ShebangNotAtTop.expected.hs b/ghcide/test/data/import-placement/ShebangNotAtTop.expected.hs new file mode 100644 index 0000000000..09e503ddd3 --- /dev/null +++ b/ghcide/test/data/import-placement/ShebangNotAtTop.expected.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE OverloadedStrings #-} +import Data.Monoid + +class Semigroup a => SomeData a +instance SomeData All + +#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])" + +f :: Int -> Int +f x = x * x diff --git a/ghcide/test/data/import-placement/ShebangNotAtTop.hs b/ghcide/test/data/import-placement/ShebangNotAtTop.hs new file mode 100644 index 0000000000..ee512102d5 --- /dev/null +++ b/ghcide/test/data/import-placement/ShebangNotAtTop.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE OverloadedStrings #-} + +class Semigroup a => SomeData a +instance SomeData All + +#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])" + +f :: Int -> Int +f x = x * x diff --git a/ghcide/test/data/import-placement/ShebangNotAtTopNoSpace.expected.hs b/ghcide/test/data/import-placement/ShebangNotAtTopNoSpace.expected.hs new file mode 100644 index 0000000000..b367314238 --- /dev/null +++ b/ghcide/test/data/import-placement/ShebangNotAtTopNoSpace.expected.hs @@ -0,0 +1,8 @@ +import Data.Monoid +class Semigroup a => SomeData a +instance SomeData All + +#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])" + +f :: Int -> Int +f x = x * x diff --git a/ghcide/test/data/import-placement/ShebangNotAtTopNoSpace.hs b/ghcide/test/data/import-placement/ShebangNotAtTopNoSpace.hs new file mode 100644 index 0000000000..5ba507a5e7 --- /dev/null +++ b/ghcide/test/data/import-placement/ShebangNotAtTopNoSpace.hs @@ -0,0 +1,7 @@ +class Semigroup a => SomeData a +instance SomeData All + +#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])" + +f :: Int -> Int +f x = x * x diff --git a/ghcide/test/data/import-placement/ShebangNotAtTopWithSpaces.expected.hs b/ghcide/test/data/import-placement/ShebangNotAtTopWithSpaces.expected.hs new file mode 100644 index 0000000000..4c6cbe3917 --- /dev/null +++ b/ghcide/test/data/import-placement/ShebangNotAtTopWithSpaces.expected.hs @@ -0,0 +1,21 @@ +{-# LANGUAGE OverloadedStrings #-} + + +{-# OPTIONS_GHC -Wall #-} + + + +{-# LANGUAGE TupleSections #-} +import Data.Monoid + + + + +class Semigroup a => SomeData a +instance SomeData All + +#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])" +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} + +addOne :: Int -> Int +addOne x = x + 1 diff --git a/ghcide/test/data/import-placement/ShebangNotAtTopWithSpaces.hs b/ghcide/test/data/import-placement/ShebangNotAtTopWithSpaces.hs new file mode 100644 index 0000000000..df312b2044 --- /dev/null +++ b/ghcide/test/data/import-placement/ShebangNotAtTopWithSpaces.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE OverloadedStrings #-} + + +{-# OPTIONS_GHC -Wall #-} + + + +{-# LANGUAGE TupleSections #-} + + + + +class Semigroup a => SomeData a +instance SomeData All + +#! nix-shell --pure -i runghc -p "haskellPackages.ghcWithPackages (hp: with hp; [ turtle ])" +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} + +addOne :: Int -> Int +addOne x = x + 1 diff --git a/ghcide/test/data/import-placement/WhereDeclLowerInFile.expected.hs b/ghcide/test/data/import-placement/WhereDeclLowerInFile.expected.hs new file mode 100644 index 0000000000..53788dfaa8 --- /dev/null +++ b/ghcide/test/data/import-placement/WhereDeclLowerInFile.expected.hs @@ -0,0 +1,18 @@ +module Asdf + (f + , where') + + where +import Data.Int + + + +f :: Int64 -> Int64 +f = id' + where id' = id + +g :: Int -> Int +g = id + +where' :: Int -> Int +where' = id diff --git a/ghcide/test/data/import-placement/WhereDeclLowerInFile.hs b/ghcide/test/data/import-placement/WhereDeclLowerInFile.hs new file mode 100644 index 0000000000..84f31f07a7 --- /dev/null +++ b/ghcide/test/data/import-placement/WhereDeclLowerInFile.hs @@ -0,0 +1,17 @@ +module Asdf + (f + , where') + + where + + + +f :: Int64 -> Int64 +f = id' + where id' = id + +g :: Int -> Int +g = id + +where' :: Int -> Int +where' = id diff --git a/ghcide/test/data/import-placement/WhereKeywordLowerInFileNoExports.expected.hs b/ghcide/test/data/import-placement/WhereKeywordLowerInFileNoExports.expected.hs new file mode 100644 index 0000000000..644fd3abab --- /dev/null +++ b/ghcide/test/data/import-placement/WhereKeywordLowerInFileNoExports.expected.hs @@ -0,0 +1,16 @@ +module Asdf + + + where +import Data.Int + + +f :: Int64 -> Int64 +f = id' + where id' = id + +g :: Int -> Int +g = id + +where' :: Int -> Int +where' = id diff --git a/ghcide/test/data/import-placement/WhereKeywordLowerInFileNoExports.hs b/ghcide/test/data/import-placement/WhereKeywordLowerInFileNoExports.hs new file mode 100644 index 0000000000..caceb1d25d --- /dev/null +++ b/ghcide/test/data/import-placement/WhereKeywordLowerInFileNoExports.hs @@ -0,0 +1,15 @@ +module Asdf + + + where + + +f :: Int64 -> Int64 +f = id' + where id' = id + +g :: Int -> Int +g = id + +where' :: Int -> Int +where' = id diff --git a/ghcide/test/exe/Main.hs b/ghcide/test/exe/Main.hs index 75bd665013..337ccb80dd 100644 --- a/ghcide/test/exe/Main.hs +++ b/ghcide/test/exe/Main.hs @@ -855,28 +855,203 @@ watchedFilesTests = testGroup "watched files" insertImportTests :: TestTree insertImportTests = testGroup "insert import" - [ checkImport "above comment at top of module" "CommentAtTop.hs" "CommentAtTop.expected.hs" "import Data.Monoid" - , checkImport "above multiple comments below" "CommentAtTopMultipleComments.hs" "CommentAtTopMultipleComments.expected.hs" "import Data.Monoid" - , checkImport "above curly brace comment" "CommentCurlyBraceAtTop.hs" "CommentCurlyBraceAtTop.expected.hs" "import Data.Monoid" - , checkImport "above multi-line comment" "MultiLineCommentAtTop.hs" "MultiLineCommentAtTop.expected.hs" "import Data.Monoid" - , checkImport "above comment with no module explicit exports" "NoExplicitExportCommentAtTop.hs" "NoExplicitExportCommentAtTop.expected.hs" "import Data.Monoid" - , checkImport "above two-dash comment with no pipe" "TwoDashOnlyComment.hs" "TwoDashOnlyComment.expected.hs" "import Data.Monoid" - , checkImport "above comment with no (module .. where) decl" "NoModuleDeclarationCommentAtTop.hs" "NoModuleDeclarationCommentAtTop.expected.hs" "import Data.Monoid" - , checkImport "comment not at top with no (module .. where) decl" "NoModuleDeclaration.hs" "NoModuleDeclaration.expected.hs" "import Data.Monoid" - , checkImport "comment not at top (data dec is)" "DataAtTop.hs" "DataAtTop.expected.hs" "import Data.Monoid" - , checkImport "comment not at top (newtype is)" "NewTypeAtTop.hs" "NewTypeAtTop.expected.hs" "import Data.Monoid" - , checkImport "with no explicit module exports" "NoExplicitExports.hs" "NoExplicitExports.expected.hs" "import Data.Monoid" - , checkImport "add to correctly placed exisiting import" "ImportAtTop.hs" "ImportAtTop.expected.hs" "import Data.Monoid" - , checkImport "add to multiple correctly placed exisiting imports" "MultipleImportsAtTop.hs" "MultipleImportsAtTop.expected.hs" "import Data.Monoid" - , checkImport "with language pragma at top of module" "LangPragmaModuleAtTop.hs" "LangPragmaModuleAtTop.expected.hs" "import Data.Monoid" - , checkImport "with language pragma and explicit module exports" "LangPragmaModuleWithComment.hs" "LangPragmaModuleWithComment.expected.hs" "import Data.Monoid" - , checkImport "with language pragma at top and no module declaration" "LanguagePragmaAtTop.hs" "LanguagePragmaAtTop.expected.hs" "import Data.Monoid" - , checkImport "with multiple lang pragmas and no module declaration" "MultipleLanguagePragmasNoModuleDeclaration.hs" "MultipleLanguagePragmasNoModuleDeclaration.expected.hs" "import Data.Monoid" - , checkImport "with pragmas and shebangs" "LanguagePragmasThenShebangs.hs" "LanguagePragmasThenShebangs.expected.hs" "import Data.Monoid" - , checkImport "with pragmas and shebangs but no comment at top" "PragmasAndShebangsNoComment.hs" "PragmasAndShebangsNoComment.expected.hs" "import Data.Monoid" - , checkImport "module decl no exports under pragmas and shebangs" "PragmasShebangsAndModuleDecl.hs" "PragmasShebangsAndModuleDecl.expected.hs" "import Data.Monoid" - , checkImport "module decl with explicit import under pragmas and shebangs" "PragmasShebangsModuleExplicitExports.hs" "PragmasShebangsModuleExplicitExports.expected.hs" "import Data.Monoid" - , checkImport "module decl and multiple imports" "ModuleDeclAndImports.hs" "ModuleDeclAndImports.expected.hs" "import Data.Monoid" + [ expectFailBecause + ("'findPositionFromImportsOrModuleDecl' function adds import directly under line with module declaration, " + ++ "not accounting for case when 'where' keyword is placed on lower line") + (checkImport + "module where keyword lower in file no exports" + "WhereKeywordLowerInFileNoExports.hs" + "WhereKeywordLowerInFileNoExports.expected.hs" + "import Data.Int") + , expectFailBecause + ("'findPositionFromImportsOrModuleDecl' function adds import directly under line with module exports list, " + ++ "not accounting for case when 'where' keyword is placed on lower line") + (checkImport + "module where keyword lower in file with exports" + "WhereDeclLowerInFile.hs" + "WhereDeclLowerInFile.expected.hs" + "import Data.Int") + , expectFailBecause + "'findNextPragmaPosition' function doesn't account for case when shebang is not placed at top of file" + (checkImport + "Shebang not at top with spaces" + "ShebangNotAtTopWithSpaces.hs" + "ShebangNotAtTopWithSpaces.expected.hs" + "import Data.Monoid") + , expectFailBecause + "'findNextPragmaPosition' function doesn't account for case when shebang is not placed at top of file" + (checkImport + "Shebang not at top no space" + "ShebangNotAtTopNoSpace.hs" + "ShebangNotAtTopNoSpace.expected.hs" + "import Data.Monoid") + , expectFailBecause + ("'findNextPragmaPosition' function doesn't account for case " + ++ "when OPTIONS_GHC pragma is not placed at top of file") + (checkImport + "OPTIONS_GHC pragma not at top with spaces" + "OptionsNotAtTopWithSpaces.hs" + "OptionsNotAtTopWithSpaces.expected.hs" + "import Data.Monoid") + , expectFailBecause + ("'findNextPragmaPosition' function doesn't account for " + ++ "case when shebang is not placed at top of file") + (checkImport + "Shebang not at top of file" + "ShebangNotAtTop.hs" + "ShebangNotAtTop.expected.hs" + "import Data.Monoid") + , expectFailBecause + ("'findNextPragmaPosition' function doesn't account for case " + ++ "when OPTIONS_GHC is not placed at top of file") + (checkImport + "OPTIONS_GHC pragma not at top of file" + "OptionsPragmaNotAtTop.hs" + "OptionsPragmaNotAtTop.expected.hs" + "import Data.Monoid") + , expectFailBecause + ("'findNextPragmaPosition' function doesn't account for case when " + ++ "OPTIONS_GHC pragma is not placed at top of file") + (checkImport + "pragma not at top with comment at top" + "PragmaNotAtTopWithCommentsAtTop.hs" + "PragmaNotAtTopWithCommentsAtTop.expected.hs" + "import Data.Monoid") + , expectFailBecause + ("'findNextPragmaPosition' function doesn't account for case when " + ++ "OPTIONS_GHC pragma is not placed at top of file") + (checkImport + "pragma not at top multiple comments" + "PragmaNotAtTopMultipleComments.hs" + "PragmaNotAtTopMultipleComments.expected.hs" + "import Data.Monoid") + , expectFailBecause + "'findNextPragmaPosition' function doesn't account for case of multiline pragmas" + (checkImport + "after multiline language pragmas" + "MultiLinePragma.hs" + "MultiLinePragma.expected.hs" + "import Data.Monoid") + , checkImport + "pragmas not at top with module declaration" + "PragmaNotAtTopWithModuleDecl.hs" + "PragmaNotAtTopWithModuleDecl.expected.hs" + "import Data.Monoid" + , checkImport + "pragmas not at top with imports" + "PragmaNotAtTopWithImports.hs" + "PragmaNotAtTopWithImports.expected.hs" + "import Data.Monoid" + , checkImport + "above comment at top of module" + "CommentAtTop.hs" + "CommentAtTop.expected.hs" + "import Data.Monoid" + , checkImport + "above multiple comments below" + "CommentAtTopMultipleComments.hs" + "CommentAtTopMultipleComments.expected.hs" + "import Data.Monoid" + , checkImport + "above curly brace comment" + "CommentCurlyBraceAtTop.hs" + "CommentCurlyBraceAtTop.expected.hs" + "import Data.Monoid" + , checkImport + "above multi-line comment" + "MultiLineCommentAtTop.hs" + "MultiLineCommentAtTop.expected.hs" + "import Data.Monoid" + , checkImport + "above comment with no module explicit exports" + "NoExplicitExportCommentAtTop.hs" + "NoExplicitExportCommentAtTop.expected.hs" + "import Data.Monoid" + , checkImport + "above two-dash comment with no pipe" + "TwoDashOnlyComment.hs" + "TwoDashOnlyComment.expected.hs" + "import Data.Monoid" + , checkImport + "above comment with no (module .. where) decl" + "NoModuleDeclarationCommentAtTop.hs" + "NoModuleDeclarationCommentAtTop.expected.hs" + "import Data.Monoid" + , checkImport + "comment not at top with no (module .. where) decl" + "NoModuleDeclaration.hs" + "NoModuleDeclaration.expected.hs" + "import Data.Monoid" + , checkImport + "comment not at top (data dec is)" + "DataAtTop.hs" + "DataAtTop.expected.hs" + "import Data.Monoid" + , checkImport + "comment not at top (newtype is)" + "NewTypeAtTop.hs" + "NewTypeAtTop.expected.hs" + "import Data.Monoid" + , checkImport + "with no explicit module exports" + "NoExplicitExports.hs" + "NoExplicitExports.expected.hs" + "import Data.Monoid" + , checkImport + "add to correctly placed exisiting import" + "ImportAtTop.hs" + "ImportAtTop.expected.hs" + "import Data.Monoid" + , checkImport + "add to multiple correctly placed exisiting imports" + "MultipleImportsAtTop.hs" + "MultipleImportsAtTop.expected.hs" + "import Data.Monoid" + , checkImport + "with language pragma at top of module" + "LangPragmaModuleAtTop.hs" + "LangPragmaModuleAtTop.expected.hs" + "import Data.Monoid" + , checkImport + "with language pragma and explicit module exports" + "LangPragmaModuleWithComment.hs" + "LangPragmaModuleWithComment.expected.hs" + "import Data.Monoid" + , checkImport + "with language pragma at top and no module declaration" + "LanguagePragmaAtTop.hs" + "LanguagePragmaAtTop.expected.hs" + "import Data.Monoid" + , checkImport + "with multiple lang pragmas and no module declaration" + "MultipleLanguagePragmasNoModuleDeclaration.hs" + "MultipleLanguagePragmasNoModuleDeclaration.expected.hs" + "import Data.Monoid" + , checkImport + "with pragmas and shebangs" + "LanguagePragmasThenShebangs.hs" + "LanguagePragmasThenShebangs.expected.hs" + "import Data.Monoid" + , checkImport + "with pragmas and shebangs but no comment at top" + "PragmasAndShebangsNoComment.hs" + "PragmasAndShebangsNoComment.expected.hs" + "import Data.Monoid" + , checkImport + "module decl no exports under pragmas and shebangs" + "PragmasShebangsAndModuleDecl.hs" + "PragmasShebangsAndModuleDecl.expected.hs" + "import Data.Monoid" + , checkImport + "module decl with explicit import under pragmas and shebangs" + "PragmasShebangsModuleExplicitExports.hs" + "PragmasShebangsModuleExplicitExports.expected.hs" + "import Data.Monoid" + , checkImport + "module decl and multiple imports" + "ModuleDeclAndImports.hs" + "ModuleDeclAndImports.expected.hs" + "import Data.Monoid" ] checkImport :: String -> FilePath -> FilePath -> T.Text -> TestTree