@@ -211,6 +211,7 @@ diagnosticTests = testGroup "diagnostics"
211codeActionTests :: TestTree
211codeActionTests :: TestTree
212codeActionTests = testGroup "code actions"
212codeActionTests = testGroup "code actions"
213 [ renameActionTests
213 [ renameActionTests
214+ , typeWildCardActionTests
216renameActionTests :: TestTree
217renameActionTests :: TestTree
@@ -289,6 +290,76 @@ renameActionTests = testGroup "rename actions"
289 liftIO $ expectedContentAfterAction @=? contentAfterAction
290 liftIO $ expectedContentAfterAction @=? contentAfterAction
293+typeWildCardActionTests :: TestTree
294+typeWildCardActionTests = testGroup "type wildcard actions"
295+ [ testSession "global signature" $ do
296+ let content = T.unlines
297+ [ "module Testing where"
301+ doc <- openDoc' "Testing.hs" "haskell" content
302+ _ <- waitForDiagnostics
303+ actionsOrCommands <- getCodeActions doc (Range (Position 2 1) (Position 2 10))
304+ let [addSignature] = [action | CACodeAction action@CodeAction { _title = actionTitle } <- actionsOrCommands
305+ , "Use type signature" `T.isInfixOf` actionTitle
307+ executeCodeAction addSignature
308+ contentAfterAction <- documentContents doc
309+ let expectedContentAfterAction = T.unlines
310+ [ "module Testing where"
311+ , "func :: (p -> p)"
314+ liftIO $ expectedContentAfterAction @=? contentAfterAction
315+ , testSession "multi-line message" $ do
316+ let content = T.unlines
317+ [ "module Testing where"
319+ , "func x y = x + y"
321+ doc <- openDoc' "Testing.hs" "haskell" content
322+ _ <- waitForDiagnostics
323+ actionsOrCommands <- getCodeActions doc (Range (Position 2 1) (Position 2 10))
324+ let [addSignature] = [action | CACodeAction action@CodeAction { _title = actionTitle } <- actionsOrCommands
325+ , "Use type signature" `T.isInfixOf` actionTitle
327+ executeCodeAction addSignature
328+ contentAfterAction <- documentContents doc
329+ let expectedContentAfterAction = T.unlines
330+ [ "module Testing where"
331+ , "func :: (Integer -> Integer -> Integer)"
332+ , "func x y = x + y"
334+ liftIO $ expectedContentAfterAction @=? contentAfterAction
335+ , testSession "local signature" $ do
336+ let content = T.unlines
337+ [ "module Testing where"
338+ , "func :: Int -> Int"
344+ doc <- openDoc' "Testing.hs" "haskell" content
345+ _ <- waitForDiagnostics
346+ actionsOrCommands <- getCodeActions doc (Range (Position 4 1) (Position 4 10))
347+ let [addSignature] = [action | CACodeAction action@CodeAction { _title = actionTitle } <- actionsOrCommands
348+ , "Use type signature" `T.isInfixOf` actionTitle
350+ executeCodeAction addSignature
351+ contentAfterAction <- documentContents doc
352+ let expectedContentAfterAction = T.unlines
353+ [ "module Testing where"
354+ , "func :: Int -> Int"
360+ liftIO $ expectedContentAfterAction @=? contentAfterAction
292----------------------------------------------------------------------
363----------------------------------------------------------------------