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