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 --lsp" "test/data/renamePass" $ do
16 doc <- openDoc "Desktop/simple.hs" "haskell"
18 skipMany loggingNotification
22 rspSymbols <- documentSymbols doc
25 let (List symbols) = fromJust (rspSymbols ^. result)
26 mainSymbol = head symbols
27 mainSymbol ^. name `shouldBe` "main"
28 mainSymbol ^. kind `shouldBe` SkFunction
29 mainSymbol ^. location . range `shouldBe` Range (Position 3 0) (Position 3 4)
30 mainSymbol ^. containerName `shouldBe` Nothing
33 -- TODO: Catch the exception in haskell-lsp-test and provide nicer output
34 let session = runSession "hie --lsp" "test/data/renamePass" $ do
35 openDoc "Desktop/simple.hs" "haskell"
36 skipMany loggingNotification
38 in session `shouldThrow` anyException
40 describe "replay session" $ do
42 replaySession "hie --lsp" "test/data/renamePass" `shouldReturn` True
44 replaySession "hie --lsp" "test/data/renameFail" `shouldReturn` False
46 describe "manual javascript session" $
48 runSession "javascript-typescript-stdio" "test/data/javascriptPass" $ do
49 doc <- openDoc "test.js" "javascript"
53 rspSymbols <- documentSymbols doc
55 let (List symbols) = fromJust (rspSymbols ^. result)
56 fooSymbol = head symbols
58 fooSymbol ^. name `shouldBe` "foo"
59 fooSymbol ^. kind `shouldBe` SkFunction
63 checkNoDiagnostics :: Session ()
64 checkNoDiagnostics = do
65 diagsNot <- notification :: Session PublishDiagnosticsNotification
66 liftIO $ diagsNot ^. params . diagnostics `shouldBe` List []
68 documentSymbols :: TextDocumentIdentifier -> Session DocumentSymbolsResponse
69 documentSymbols doc = do
70 sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc)