@@ -13,12 +13,12 @@ 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 )
16
17
17
18
tests :: TestTree
18
19
tests = testGroup " completions" [
19
20
testCase " works" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
20
21
doc <- openDoc " Completion.hs" " haskell"
21
- _ <- waitForDiagnosticsFrom doc
22
22
23
23
let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " put"
24
24
_ <- applyEdit doc te
@@ -35,7 +35,6 @@ tests = testGroup "completions" [
35
35
, ignoreTestBecause " no support for itemCompletion/resolve requests"
36
36
$ testCase " itemCompletion/resolve works" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
37
37
doc <- openDoc " Completion.hs" " haskell"
38
- _ <- waitForDiagnosticsFrom doc
39
38
40
39
let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " put"
41
40
_ <- applyEdit doc te
@@ -54,7 +53,8 @@ tests = testGroup "completions" [
54
53
55
54
, testCase " completes imports" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
56
55
doc <- openDoc " Completion.hs" " haskell"
57
- _ <- waitForDiagnosticsFrom doc
56
+
57
+ liftIO $ sleep 4
58
58
59
59
let te = TextEdit (Range (Position 1 17 ) (Position 1 26 )) " Data.M"
60
60
_ <- applyEdit doc te
@@ -68,7 +68,8 @@ tests = testGroup "completions" [
68
68
69
69
, testCase " completes qualified imports" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
70
70
doc <- openDoc " Completion.hs" " haskell"
71
- _ <- waitForDiagnosticsFrom doc
71
+
72
+ liftIO $ sleep 4
72
73
73
74
let te = TextEdit (Range (Position 2 17 ) (Position 1 25 )) " Dat"
74
75
_ <- applyEdit doc te
@@ -82,7 +83,8 @@ tests = testGroup "completions" [
82
83
83
84
, testCase " completes language extensions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
84
85
doc <- openDoc " Completion.hs" " haskell"
85
- _ <- waitForDiagnosticsFrom doc
86
+
87
+ liftIO $ sleep 4
86
88
87
89
let te = TextEdit (Range (Position 0 24 ) (Position 0 31 )) " "
88
90
_ <- applyEdit doc te
@@ -95,7 +97,8 @@ tests = testGroup "completions" [
95
97
96
98
, testCase " completes pragmas" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
97
99
doc <- openDoc " Completion.hs" " haskell"
98
- _ <- waitForDiagnosticsFrom doc
100
+
101
+ liftIO $ sleep 4
99
102
100
103
let te = TextEdit (Range (Position 0 4 ) (Position 0 34 )) " "
101
104
_ <- applyEdit doc te
@@ -110,7 +113,6 @@ tests = testGroup "completions" [
110
113
111
114
, testCase " completes pragmas no close" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
112
115
doc <- openDoc " Completion.hs" " haskell"
113
- _ <- waitForDiagnosticsFrom doc
114
116
115
117
let te = TextEdit (Range (Position 0 4 ) (Position 0 24 )) " "
116
118
_ <- applyEdit doc te
@@ -125,7 +127,8 @@ tests = testGroup "completions" [
125
127
126
128
, testCase " completes options pragma" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
127
129
doc <- openDoc " Completion.hs" " haskell"
128
- _ <- waitForDiagnosticsFrom doc
130
+
131
+ liftIO $ sleep 4
129
132
130
133
let te = TextEdit (Range (Position 0 4 ) (Position 0 34 )) " OPTIONS"
131
134
_ <- applyEdit doc te
@@ -141,8 +144,6 @@ tests = testGroup "completions" [
141
144
, testCase " completes ghc options pragma values" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
142
145
doc <- openDoc " Completion.hs" " haskell"
143
146
144
- _ <- waitForDiagnosticsFrom doc
145
-
146
147
let te = TextEdit (Range (Position 0 0 ) (Position 0 0 )) " {-# OPTIONS_GHC -Wno-red #-}\n "
147
148
_ <- applyEdit doc te
148
149
@@ -156,7 +157,7 @@ tests = testGroup "completions" [
156
157
157
158
, testCase " completes with no prefix" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
158
159
doc <- openDoc " Completion.hs" " haskell"
159
- _ <- waitForDiagnosticsFrom doc
160
+
160
161
compls <- getCompletions doc (Position 5 7 )
161
162
liftIO $ any ((== " !!" ) . (^. label)) compls @? " "
162
163
@@ -175,7 +176,7 @@ tests = testGroup "completions" [
175
176
176
177
, testCase " have implicit foralls on basic polymorphic types" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
177
178
doc <- openDoc " Completion.hs" " haskell"
178
- _ <- waitForDiagnosticsFrom doc
179
+
179
180
let te = TextEdit (Range (Position 5 7 ) (Position 5 9 )) " id"
180
181
_ <- applyEdit doc te
181
182
compls <- getCompletions doc (Position 5 9 )
@@ -185,7 +186,7 @@ tests = testGroup "completions" [
185
186
186
187
, testCase " have implicit foralls with multiple type variables" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
187
188
doc <- openDoc " Completion.hs" " haskell"
188
- _ <- waitForDiagnosticsFrom doc
189
+
189
190
let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " flip"
190
191
_ <- applyEdit doc te
191
192
compls <- getCompletions doc (Position 5 11 )
@@ -201,7 +202,6 @@ snippetTests :: TestTree
201
202
snippetTests = testGroup " snippets" [
202
203
testCase " work for argumentless constructors" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
203
204
doc <- openDoc " Completion.hs" " haskell"
204
- _ <- waitForDiagnosticsFrom doc
205
205
206
206
let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " Nothing"
207
207
_ <- applyEdit doc te
@@ -214,7 +214,6 @@ snippetTests = testGroup "snippets" [
214
214
215
215
, testCase " work for polymorphic types" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
216
216
doc <- openDoc " Completion.hs" " haskell"
217
- _ <- waitForDiagnosticsFrom doc
218
217
219
218
let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " fold"
220
219
_ <- applyEdit doc te
@@ -229,7 +228,6 @@ snippetTests = testGroup "snippets" [
229
228
230
229
, testCase " work for complex types" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
231
230
doc <- openDoc " Completion.hs" " haskell"
232
- _ <- waitForDiagnosticsFrom doc
233
231
234
232
let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " mapM"
235
233
_ <- applyEdit doc te
@@ -244,7 +242,6 @@ snippetTests = testGroup "snippets" [
244
242
245
243
, testCase " work for infix functions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
246
244
doc <- openDoc " Completion.hs" " haskell"
247
- _ <- waitForDiagnosticsFrom doc
248
245
249
246
let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " even `filte"
250
247
_ <- applyEdit doc te
@@ -259,7 +256,6 @@ snippetTests = testGroup "snippets" [
259
256
260
257
, testCase " work for infix functions in backticks" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
261
258
doc <- openDoc " Completion.hs" " haskell"
262
- _ <- waitForDiagnosticsFrom doc
263
259
264
260
let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " even `filte`"
265
261
_ <- applyEdit doc te
@@ -274,7 +270,6 @@ snippetTests = testGroup "snippets" [
274
270
275
271
, testCase " work for qualified infix functions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
276
272
doc <- openDoc " Completion.hs" " haskell"
277
- _ <- waitForDiagnosticsFrom doc
278
273
279
274
let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " \"\" `Data.List.interspe"
280
275
_ <- applyEdit doc te
@@ -289,7 +284,6 @@ snippetTests = testGroup "snippets" [
289
284
290
285
, testCase " work for qualified infix functions in backticks" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
291
286
doc <- openDoc " Completion.hs" " haskell"
292
- _ <- waitForDiagnosticsFrom doc
293
287
294
288
let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " \"\" `Data.List.interspe`"
295
289
_ <- applyEdit doc te
@@ -305,7 +299,6 @@ snippetTests = testGroup "snippets" [
305
299
, ignoreTestBecause " ghcide does not support the completionSnippetsOn option" $
306
300
testCase " respects lsp configuration" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
307
301
doc <- openDoc " Completion.hs" " haskell"
308
- _ <- waitForDiagnosticsFrom doc
309
302
310
303
let config = object [ " haskell" .= (object [" completionSnippetsOn" .= False ])]
311
304
@@ -316,7 +309,6 @@ snippetTests = testGroup "snippets" [
316
309
317
310
, testCase " respects client capabilities" $ runSession hlsCommand noSnippetsCaps " test/testdata/completion" $ do
318
311
doc <- openDoc " Completion.hs" " haskell"
319
- _ <- waitForDiagnosticsFrom doc
320
312
321
313
checkNoSnippets doc
322
314
]
@@ -349,23 +341,23 @@ contextTests :: TestTree
349
341
contextTests = testGroup " contexts" [
350
342
testCase " only provides type suggestions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
351
343
doc <- openDoc " Context.hs" " haskell"
352
- _ <- waitForDiagnosticsFrom doc
344
+
353
345
compls <- getCompletions doc (Position 2 17 )
354
346
liftIO $ do
355
347
compls `shouldContainCompl` " Integer"
356
348
compls `shouldNotContainCompl` " interact"
357
349
358
350
, testCase " only provides value suggestions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
359
351
doc <- openDoc " Context.hs" " haskell"
360
- _ <- waitForDiagnosticsFrom doc
352
+
361
353
compls <- getCompletions doc (Position 3 9 )
362
354
liftIO $ do
363
355
compls `shouldContainCompl` " abs"
364
356
compls `shouldNotContainCompl` " Applicative"
365
357
366
358
, testCase " completes qualified type suggestions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
367
359
doc <- openDoc " Context.hs" " haskell"
368
- _ <- waitForDiagnosticsFrom doc
360
+
369
361
compls <- getCompletions doc (Position 2 26 )
370
362
liftIO $ do
371
363
compls `shouldNotContainCompl` " forkOn"
0 commit comments