Skip to content

Commit 6bd22a1

Browse files
committed
Fix some inaccuracies in tests
1 parent 6200a4c commit 6bd22a1

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

test/functional/Completion.hs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import Test.Tasty
1313
import Test.Tasty.ExpectedFailure (ignoreTestBecause)
1414
import Test.Tasty.HUnit
1515
import qualified Data.Text as T
16-
import System.Time.Extra (sleep)
1716

1817
tests :: TestTree
1918
tests = testGroup "completions" [
@@ -54,12 +53,12 @@ tests = testGroup "completions" [
5453
, testCase "completes imports" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
5554
doc <- openDoc "Completion.hs" "haskell"
5655

57-
liftIO $ sleep 4
56+
_ <- waitForDiagnostics
5857

5958
let te = TextEdit (Range (Position 1 17) (Position 1 26)) "Data.M"
6059
_ <- applyEdit doc te
6160

62-
compls <- getCompletions doc (Position 1 22)
61+
compls <- getCompletions doc (Position 1 23)
6362
let item = head $ filter ((== "Maybe") . (^. label)) compls
6463
liftIO $ do
6564
item ^. label @?= "Maybe"
@@ -69,22 +68,22 @@ tests = testGroup "completions" [
6968
, testCase "completes qualified imports" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
7069
doc <- openDoc "Completion.hs" "haskell"
7170

72-
liftIO $ sleep 4
71+
_ <- waitForDiagnostics
7372

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"
7574
_ <- applyEdit doc te
7675

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
7978
liftIO $ do
80-
item ^. label @?= "Data.List"
79+
item ^. label @?= "List"
8180
item ^. detail @?= Just "Data.List"
8281
item ^. kind @?= Just CiModule
8382

8483
, testCase "completes language extensions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
8584
doc <- openDoc "Completion.hs" "haskell"
8685

87-
liftIO $ sleep 4
86+
_ <- waitForDiagnostics
8887

8988
let te = TextEdit (Range (Position 0 24) (Position 0 31)) ""
9089
_ <- applyEdit doc te
@@ -98,7 +97,7 @@ tests = testGroup "completions" [
9897
, testCase "completes pragmas" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
9998
doc <- openDoc "Completion.hs" "haskell"
10099

101-
liftIO $ sleep 4
100+
_ <- waitForDiagnostics
102101

103102
let te = TextEdit (Range (Position 0 4) (Position 0 34)) ""
104103
_ <- applyEdit doc te
@@ -128,7 +127,7 @@ tests = testGroup "completions" [
128127
, testCase "completes options pragma" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
129128
doc <- openDoc "Completion.hs" "haskell"
130129

131-
liftIO $ sleep 4
130+
_ <- waitForDiagnostics
132131

133132
let te = TextEdit (Range (Position 0 4) (Position 0 34)) "OPTIONS"
134133
_ <- applyEdit doc te
@@ -159,7 +158,7 @@ tests = testGroup "completions" [
159158
doc <- openDoc "Completion.hs" "haskell"
160159

161160
compls <- getCompletions doc (Position 5 7)
162-
liftIO $ any ((== "!!") . (^. label)) compls @? ""
161+
liftIO $ assertBool "Expected completions" $ not $ null compls
163162

164163
-- See https://github.com/haskell/haskell-ide-engine/issues/903
165164
, testCase "strips compiler generated stuff from completions" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do

0 commit comments

Comments
 (0)