@@ -211,6 +211,7 @@ diagnosticTests = testGroup "diagnostics"
211211codeActionTests :: TestTree
212212codeActionTests = testGroup "code actions"
213213 [ renameActionTests
214+ , typeWildCardActionTests
214215 ]
215216
216217renameActionTests :: TestTree
@@ -289,6 +290,76 @@ renameActionTests = testGroup "rename actions"
289290 liftIO $ expectedContentAfterAction @=? contentAfterAction
290291 ]
291292
293+typeWildCardActionTests :: TestTree
294+typeWildCardActionTests = testGroup "type wildcard actions"
295+ [ testSession "global signature" $ do
296+ let content = T.unlines
297+ [ "module Testing where"
298+ , "func :: _"
299+ , "func x = x"
300+ ]
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
306+ ]
307+ executeCodeAction addSignature
308+ contentAfterAction <- documentContents doc
309+ let expectedContentAfterAction = T.unlines
310+ [ "module Testing where"
311+ , "func :: (p -> p)"
312+ , "func x = x"
313+ ]
314+ liftIO $ expectedContentAfterAction @=? contentAfterAction
315+ , testSession "multi-line message" $ do
316+ let content = T.unlines
317+ [ "module Testing where"
318+ , "func :: _"
319+ , "func x y = x + y"
320+ ]
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
326+ ]
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"
333+ ]
334+ liftIO $ expectedContentAfterAction @=? contentAfterAction
335+ , testSession "local signature" $ do
336+ let content = T.unlines
337+ [ "module Testing where"
338+ , "func :: Int -> Int"
339+ , "func x ="
340+ , " let y :: _"
341+ , " y = x * 2"
342+ , " in y"
343+ ]
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
349+ ]
350+ executeCodeAction addSignature
351+ contentAfterAction <- documentContents doc
352+ let expectedContentAfterAction = T.unlines
353+ [ "module Testing where"
354+ , "func :: Int -> Int"
355+ , "func x ="
356+ , " let y :: (Int)"
357+ , " y = x * 2"
358+ , " in y"
359+ ]
360+ liftIO $ expectedContentAfterAction @=? contentAfterAction
361+ ]
362+
292363----------------------------------------------------------------------
293364-- Utils
294365