@@ -13,7 +13,6 @@ import Test.Tasty
13
13
import Test.Tasty.ExpectedFailure (ignoreTestBecause )
14
14
import Test.Tasty.HUnit
15
15
import qualified Data.Text as T
16
- import System.Time.Extra (sleep )
17
16
18
17
tests :: TestTree
19
18
tests = testGroup " completions" [
@@ -54,12 +53,12 @@ tests = testGroup "completions" [
54
53
, testCase " completes imports" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
55
54
doc <- openDoc " Completion.hs" " haskell"
56
55
57
- liftIO $ sleep 4
56
+ _ <- waitForDiagnostics
58
57
59
58
let te = TextEdit (Range (Position 1 17 ) (Position 1 26 )) " Data.M"
60
59
_ <- applyEdit doc te
61
60
62
- compls <- getCompletions doc (Position 1 22 )
61
+ compls <- getCompletions doc (Position 1 23 )
63
62
let item = head $ filter ((== " Maybe" ) . (^. label)) compls
64
63
liftIO $ do
65
64
item ^. label @?= " Maybe"
@@ -69,22 +68,22 @@ tests = testGroup "completions" [
69
68
, testCase " completes qualified imports" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
70
69
doc <- openDoc " Completion.hs" " haskell"
71
70
72
- liftIO $ sleep 4
71
+ _ <- waitForDiagnostics
73
72
74
- let te = TextEdit (Range (Position 2 17 ) (Position 1 25 )) " Dat "
73
+ let te = TextEdit (Range (Position 2 17 ) (Position 2 25 )) " Data.L "
75
74
_ <- applyEdit doc te
76
75
77
- compls <- getCompletions doc (Position 1 19 )
78
- let item = head $ filter ((== " Data. List" ) . (^. label)) compls
76
+ compls <- getCompletions doc (Position 2 24 )
77
+ let item = head $ filter ((== " List" ) . (^. label)) compls
79
78
liftIO $ do
80
- item ^. label @?= " Data. List"
79
+ item ^. label @?= " List"
81
80
item ^. detail @?= Just " Data.List"
82
81
item ^. kind @?= Just CiModule
83
82
84
83
, testCase " completes language extensions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
85
84
doc <- openDoc " Completion.hs" " haskell"
86
85
87
- liftIO $ sleep 4
86
+ _ <- waitForDiagnostics
88
87
89
88
let te = TextEdit (Range (Position 0 24 ) (Position 0 31 )) " "
90
89
_ <- applyEdit doc te
@@ -98,7 +97,7 @@ tests = testGroup "completions" [
98
97
, testCase " completes pragmas" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
99
98
doc <- openDoc " Completion.hs" " haskell"
100
99
101
- liftIO $ sleep 4
100
+ _ <- waitForDiagnostics
102
101
103
102
let te = TextEdit (Range (Position 0 4 ) (Position 0 34 )) " "
104
103
_ <- applyEdit doc te
@@ -128,7 +127,7 @@ tests = testGroup "completions" [
128
127
, testCase " completes options pragma" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
129
128
doc <- openDoc " Completion.hs" " haskell"
130
129
131
- liftIO $ sleep 4
130
+ _ <- waitForDiagnostics
132
131
133
132
let te = TextEdit (Range (Position 0 4 ) (Position 0 34 )) " OPTIONS"
134
133
_ <- applyEdit doc te
@@ -159,7 +158,7 @@ tests = testGroup "completions" [
159
158
doc <- openDoc " Completion.hs" " haskell"
160
159
161
160
compls <- getCompletions doc (Position 5 7 )
162
- liftIO $ any (( == " !! " ) . ( ^. label)) compls @? " "
161
+ liftIO $ assertBool " Expected completions " $ not $ null compls
163
162
164
163
-- See https://github.com/haskell/haskell-ide-engine/issues/903
165
164
, testCase " strips compiler generated stuff from completions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
0 commit comments