11{-# LANGUAGE OverloadedStrings #-}
2- {-# OPTIONS_GHC -Wno-incomplete-patterns #-}
2+
33module Main
44 ( main
55 ) where
@@ -12,7 +12,6 @@ import Ide.Plugin.Pragmas
1212import qualified Language.LSP.Protocol.Lens as L
1313import System.FilePath
1414import Test.Hls
15- import Test.Hls.Util (onlyWorkForGhcVersions )
1615
1716main :: IO ()
1817main = defaultTestRunner tests
@@ -80,9 +79,6 @@ codeActionTests =
8079 , codeActionTestWithDisableWarning " before doc comments" " UnusedImports" [(" Disable \" unused-imports\" warnings" , " Contains unused-imports code action" )]
8180 ]
8281
83- ghc94regression :: String
84- ghc94regression = " to be reported"
85-
8682codeActionTestWithPragmasSuggest :: String -> FilePath -> [(T. Text , String )] -> TestTree
8783codeActionTestWithPragmasSuggest = codeActionTestWith pragmasSuggestPlugin
8884
@@ -105,8 +101,7 @@ codeActionTestWith descriptor testComment fp actions =
105101codeActionTests' :: TestTree
106102codeActionTests' =
107103 testGroup " additional code actions"
108- [
109- goldenWithPragmas pragmasSuggestPlugin " no duplication" " NamedFieldPuns" $ \ doc -> do
104+ [ goldenWithPragmas pragmasSuggestPlugin " no duplication" " NamedFieldPuns" $ \ doc -> do
110105 _ <- waitForDiagnosticsFrom doc
111106 cas <- map fromAction <$> getCodeActions doc (Range (Position 8 9 ) (Position 8 9 ))
112107 ca <- liftIO $ case cas of
@@ -124,18 +119,17 @@ codeActionTests' =
124119completionTests :: TestTree
125120completionTests =
126121 testGroup " completions"
127- [ completionTest " completes pragmas" " Completion.hs" " " " LANGUAGE" (Just InsertTextFormat_Snippet ) (Just " LANGUAGE ${1:extension} #-}" ) (Just " {-# LANGUAGE #-}" ) [0 , 4 , 0 , 34 , 0 , 4 ]
128- , completionTest " completes pragmas with existing closing pragma bracket" " Completion.hs" " " " LANGUAGE" (Just InsertTextFormat_Snippet ) (Just " LANGUAGE ${1:extension}" ) (Just " {-# LANGUAGE #-}" ) [0 , 4 , 0 , 31 , 0 , 4 ]
129- , completionTest " completes pragmas with existing closing comment bracket" " Completion.hs" " " " LANGUAGE" (Just InsertTextFormat_Snippet ) (Just " LANGUAGE ${1:extension} #" ) (Just " {-# LANGUAGE #-}" ) [0 , 4 , 0 , 32 , 0 , 4 ]
130- , completionTest " completes pragmas with existing closing bracket" " Completion.hs" " " " LANGUAGE" (Just InsertTextFormat_Snippet ) (Just " LANGUAGE ${1:extension} #-" ) (Just " {-# LANGUAGE #-}" ) [0 , 4 , 0 , 33 , 0 , 4 ]
131- , completionTest " completes options pragma" " Completion.hs" " OPTIONS" " OPTIONS_GHC" (Just InsertTextFormat_Snippet ) (Just " OPTIONS_GHC -${1:option} #-}" ) (Just " {-# OPTIONS_GHC #-}" ) [0 , 4 , 0 , 34 , 0 , 4 ]
132- , completionTest " completes ghc options pragma values" " Completion.hs" " {-# OPTIONS_GHC -Wno-red #-}\n " " Wno-redundant-constraints" Nothing Nothing Nothing [0 , 0 , 0 , 0 , 0 , 24 ]
133- , completionTest " completes language extensions" " Completion.hs" " " " OverloadedStrings" Nothing Nothing Nothing [0 , 24 , 0 , 31 , 0 , 24 ]
134- , completionTest " completes language extensions case insensitive" " Completion.hs" " lAnGuaGe Overloaded" " OverloadedStrings" Nothing Nothing Nothing [0 , 4 , 0 , 34 , 0 , 24 ]
135- , completionTest " completes the Strict language extension" " Completion.hs" " Str" " Strict" Nothing Nothing Nothing [0 , 13 , 0 , 31 , 0 , 16 ]
136- , completionTest " completes No- language extensions" " Completion.hs" " NoOverload" " NoOverloadedStrings" Nothing Nothing Nothing [0 , 13 , 0 , 31 , 0 , 23 ]
137- , onlyWorkForGhcVersions (>= GHC92 ) " GHC2021 flag introduced since ghc9.2" $
138- completionTest " completes GHC2021 extensions" " Completion.hs" " ghc" " GHC2021" Nothing Nothing Nothing [0 , 13 , 0 , 31 , 0 , 16 ]
122+ [ completionTest " completes pragmas" " Completion.hs" " " " LANGUAGE" (Just InsertTextFormat_Snippet ) (Just " LANGUAGE ${1:extension} #-}" ) (Just " {-# LANGUAGE #-}" ) (0 , 4 , 0 , 34 , 0 , 4 )
123+ , completionTest " completes pragmas with existing closing pragma bracket" " Completion.hs" " " " LANGUAGE" (Just InsertTextFormat_Snippet ) (Just " LANGUAGE ${1:extension}" ) (Just " {-# LANGUAGE #-}" ) (0 , 4 , 0 , 31 , 0 , 4 )
124+ , completionTest " completes pragmas with existing closing comment bracket" " Completion.hs" " " " LANGUAGE" (Just InsertTextFormat_Snippet ) (Just " LANGUAGE ${1:extension} #" ) (Just " {-# LANGUAGE #-}" ) (0 , 4 , 0 , 32 , 0 , 4 )
125+ , completionTest " completes pragmas with existing closing bracket" " Completion.hs" " " " LANGUAGE" (Just InsertTextFormat_Snippet ) (Just " LANGUAGE ${1:extension} #-" ) (Just " {-# LANGUAGE #-}" ) (0 , 4 , 0 , 33 , 0 , 4 )
126+ , completionTest " completes options pragma" " Completion.hs" " OPTIONS" " OPTIONS_GHC" (Just InsertTextFormat_Snippet ) (Just " OPTIONS_GHC -${1:option} #-}" ) (Just " {-# OPTIONS_GHC #-}" ) (0 , 4 , 0 , 34 , 0 , 4 )
127+ , completionTest " completes ghc options pragma values" " Completion.hs" " {-# OPTIONS_GHC -Wno-red #-}\n " " Wno-redundant-constraints" Nothing Nothing Nothing (0 , 0 , 0 , 0 , 0 , 24 )
128+ , completionTest " completes language extensions" " Completion.hs" " " " OverloadedStrings" Nothing Nothing Nothing (0 , 24 , 0 , 31 , 0 , 24 )
129+ , completionTest " completes language extensions case insensitive" " Completion.hs" " lAnGuaGe Overloaded" " OverloadedStrings" Nothing Nothing Nothing (0 , 4 , 0 , 34 , 0 , 24 )
130+ , completionTest " completes the Strict language extension" " Completion.hs" " Str" " Strict" Nothing Nothing Nothing (0 , 13 , 0 , 31 , 0 , 16 )
131+ , completionTest " completes No- language extensions" " Completion.hs" " NoOverload" " NoOverloadedStrings" Nothing Nothing Nothing (0 , 13 , 0 , 31 , 0 , 23 )
132+ , completionTest " completes GHC2021 extensions" " Completion.hs" " ghc" " GHC2021" Nothing Nothing Nothing (0 , 13 , 0 , 31 , 0 , 16 )
139133 ]
140134
141135completionSnippetTests :: TestTree
@@ -151,7 +145,7 @@ completionSnippetTests =
151145 in completionTest (T. unpack label)
152146 " Completion.hs" input label (Just InsertTextFormat_Snippet )
153147 (Just $ " {-# " <> insertText <> " #-}" ) (Just detail)
154- [ 0 , 0 , 0 , 34 , 0 , fromIntegral $ T. length input] )
148+ ( 0 , 0 , 0 , 34 , 0 , fromIntegral $ T. length input) )
155149
156150dontSuggestCompletionTests :: TestTree
157151dontSuggestCompletionTests =
@@ -162,7 +156,7 @@ dontSuggestCompletionTests =
162156 , provideNoCompletionsTest " when no word has been typed" " Completion.hs" Nothing (Position 3 0 )
163157 , provideNoCompletionsTest " when expecting auto complete on modules" " Completion.hs" (Just $ mkEdit (8 ,6 ) (8 ,8 ) " Data.Maybe.WA" ) (Position 8 19 )
164158 ]
165- individualPragmaTests = validPragmas <&> \ (insertText ,label,detail ,appearWhere) ->
159+ individualPragmaTests = validPragmas <&> \ (_insertText ,label,_detail ,appearWhere) ->
166160 let completionPrompt = T. toLower $ T. init label
167161 promptLen = fromIntegral (T. length completionPrompt)
168162 in case appearWhere of
@@ -176,8 +170,8 @@ mkEdit :: (UInt,UInt) -> (UInt,UInt) -> T.Text -> TextEdit
176170mkEdit (startLine, startCol) (endLine, endCol) newText =
177171 TextEdit (Range (Position startLine startCol) (Position endLine endCol)) newText
178172
179- completionTest :: String -> FilePath -> T. Text -> T. Text -> Maybe InsertTextFormat -> Maybe T. Text -> Maybe T. Text -> [ UInt ] -> TestTree
180- completionTest testComment fileName replacementText expectedLabel expectedFormat expectedInsertText detail [ delFromLine, delFromCol, delToLine, delToCol, completeAtLine, completeAtCol] =
173+ completionTest :: String -> FilePath -> T. Text -> T. Text -> Maybe InsertTextFormat -> Maybe T. Text -> Maybe T. Text -> ( UInt , UInt , UInt , UInt , UInt , UInt ) -> TestTree
174+ completionTest testComment fileName replacementText expectedLabel expectedFormat expectedInsertText detail ( delFromLine, delFromCol, delToLine, delToCol, completeAtLine, completeAtCol) =
181175 testCase testComment $ runSessionWithServer def pragmasCompletionPlugin testDataDir $ do
182176 doc <- openDoc fileName " haskell"
183177 _ <- waitForDiagnostics
0 commit comments