forked from haskell/haskell-language-server
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFunctionalBadProject.hs
28 lines (24 loc) · 1.26 KB
/
FunctionalBadProject.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{-# LANGUAGE OverloadedStrings #-}
module FunctionalBadProject (tests) where
import Control.Lens
import qualified Data.Text as T
import qualified Language.LSP.Protocol.Lens as L
import Test.Hls
import Test.Hls.Command
tests :: TestTree
tests = testGroup "behaviour on malformed projects"
[ testCase "Missing module diagnostic" $ do
runSession hlsLspCommand fullCaps "test/testdata/missingModuleTest/missingModule/" $ do
doc <- openDoc "src/MyLib.hs" "haskell"
[diag] <- waitForDiagnosticsFrom doc
liftIO $ assertBool "missing module name" $ "MyLib" `T.isInfixOf` (diag ^. L.message)
liftIO $ assertBool "module missing context" $ "may not be listed" `T.isInfixOf` (diag ^. L.message)
, testCase "Missing module diagnostic - no matching prefix" $ do
runSession hlsLspCommand fullCaps "test/testdata/missingModuleTest/noPrefixMatch/" $ do
doc <- openDoc "app/Other.hs" "haskell"
[diag] <- waitForDiagnosticsFrom doc
liftIO $ assertBool "missing module name" $
"Other" `T.isInfixOf` (diag ^. L.message)
liftIO $ assertBool "hie-bios message" $
"Cabal" `T.isInfixOf` (diag ^. L.message)
]