1 {-# LANGUAGE DuplicateRecordFields #-}
2 {-# LANGUAGE OverloadedStrings #-}
5 import Control.Monad.IO.Class
6 import Control.Lens hiding (List)
7 import Language.Haskell.LSP.Test
8 import Language.Haskell.LSP.Test.Replay
9 import Language.Haskell.LSP.Types
13 describe "manual session" $ do
15 runSession "hie" "test/recordings/renamePass" $ do
16 doc <- openDoc "Desktop/simple.hs" "haskell"
18 skipMany loggingNotification
20 diagsNot <- notification :: Session PublishDiagnosticsNotification
22 liftIO $ diagsNot ^. params . diagnostics `shouldBe` List []
24 sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc)
26 rspSymbols <- response :: Session DocumentSymbolsResponse
29 let (List symbols) = fromJust (rspSymbols ^. result)
30 mainSymbol = head symbols
31 mainSymbol ^. name `shouldBe` "main"
32 mainSymbol ^. kind `shouldBe` SkFunction
33 mainSymbol ^. location . range `shouldBe` Range (Position 3 0) (Position 3 4)
34 mainSymbol ^. containerName `shouldBe` Nothing
37 -- TODO: Catch the exception in haskell-lsp-test and provide nicer output
38 let session = runSession "hie" "test/recordings/renamePass" $ do
39 openDoc "Desktop/simple.hs" "haskell"
40 skipMany loggingNotification
42 in session `shouldThrow` anyException
44 describe "replay session" $ do
46 replaySession "hie" "test/recordings/renamePass" `shouldReturn` True
48 replaySession "hie" "test/recordings/renameFail" `shouldReturn` False