1{-# LANGUAGE OverloadedStrings #-}
2module Highlight (tests) where
3
4import           Test.Hls
5import           Test.Hls.Command
6
7tests :: TestTree
8tests = testGroup "highlight" [
9    testCase "works" $ runSession (hlsCommand ++ " --test") fullCaps "test/testdata" $ do
10        doc <- openDoc "Highlight.hs" "haskell"
11        _ <- waitForDiagnosticsFrom doc
12        highlights <- getHighlights doc (Position 2 2)
13        liftIO $ do
14            let hls =
15                    [ DocumentHighlight (mkRange 2 0 2 3) (Just HkWrite)
16                    , DocumentHighlight (mkRange 4 22 4 25) (Just HkRead)
17                    , DocumentHighlight (mkRange 3 6 3 9) (Just HkRead)
18                    , DocumentHighlight (mkRange 1 0 1 3) (Just HkRead)]
19            mapM_ (\x -> x `elem` highlights @? "Contains highlight") hls
20    ]
21    where
22        mkRange sl sc el ec = Range (Position sl sc) (Position el ec)
23