X-Git-Url: http://git.lukelau.me/?a=blobdiff_plain;f=test%2FTest.hs;h=79bb30312668857a68322a99a3ad46a34896015f;hb=25c948d3bfc9f3876805377a0b923570bd0330a0;hp=3c53aec67dd292859abc0285e939da6d3d3d532f;hpb=bd6901688e6c9d8332fea161260d32666885f9ed;p=opengl.git diff --git a/test/Test.hs b/test/Test.hs index 3c53aec..79bb303 100644 --- a/test/Test.hs +++ b/test/Test.hs @@ -2,6 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DeriveAnyClass #-} + import Test.Hspec import Data.Aeson import Data.Default @@ -26,9 +27,9 @@ main = hspec $ do skipMany loggingNotification - checkNoDiagnostics + noDiagnostics - rspSymbols <- documentSymbols doc + rspSymbols <- getDocumentSymbols doc liftIO $ do let (List symbols) = fromJust (rspSymbols ^. result) @@ -46,7 +47,7 @@ main = hspec $ do anyRequest in session `shouldThrow` anyException it "can get initialize response" $ runSession "hie --lsp" "test/data/renamePass" $ do - rsp <- getInitializeResponse + rsp <- initializeResponse liftIO $ rsp ^. result `shouldNotBe` Nothing it "can register specific capabilities" $ do @@ -99,9 +100,9 @@ main = hspec $ do runSession "javascript-typescript-stdio" "test/data/javascriptPass" $ do doc <- openDoc "test.js" "javascript" - checkNoDiagnostics + noDiagnostics - rspSymbols <- documentSymbols doc + rspSymbols <- getDocumentSymbols doc let (List symbols) = fromJust (rspSymbols ^. result) fooSymbol = head symbols @@ -109,7 +110,7 @@ main = hspec $ do fooSymbol ^. name `shouldBe` "foo" fooSymbol ^. kind `shouldBe` SkFunction - describe "text document state" $ + describe "text document VFS" $ it "sends back didChange notifications" $ runSession "hie --lsp" "test/data/refactor" $ do doc <- openDoc "Main.hs" "haskell" @@ -129,11 +130,28 @@ main = hspec $ do u `shouldBe` doc ^. uri es `shouldBe` [TextEdit (Range (Position 1 0) (Position 1 18)) "main = return 42"] - checkNoDiagnostics + noDiagnostics contents <- documentContents doc liftIO $ contents `shouldBe` "main :: IO Int\nmain = return 42" + describe "documentEdit" $ + it "automatically consumes applyedit requests" $ + runSession "hie --lsp" "test/data/refactor" $ do + doc <- openDoc "Main.hs" "haskell" + + let args = toJSON $ AOP (doc ^. uri) + (Position 1 14) + "Redundant bracket" + reqParams = ExecuteCommandParams "applyrefact:applyOne" (Just (List [args])) + sendRequest WorkspaceExecuteCommand reqParams + skipMany anyNotification + _ <- response :: Session ExecuteCommandResponse + + contents <- getDocumentEdit doc + liftIO $ contents `shouldBe` "main :: IO Int\nmain = return 42" + noDiagnostics + parsingSpec data ApplyOneParams = AOP @@ -142,12 +160,3 @@ data ApplyOneParams = AOP , hintTitle :: String } deriving (Generic, ToJSON) -checkNoDiagnostics :: Session () -checkNoDiagnostics = do - diagsNot <- notification :: Session PublishDiagnosticsNotification - liftIO $ diagsNot ^. params . diagnostics `shouldBe` List [] - -documentSymbols :: TextDocumentIdentifier -> Session DocumentSymbolsResponse -documentSymbols doc = do - sendRequest TextDocumentDocumentSymbol (DocumentSymbolParams doc) - response