Skip to content

Commit 143f8f1

Browse files
rndnoisekritzcreek
authored andcommitted
Make REPL completion tests faster (purescript#3234)
1 parent f999179 commit 143f8f1

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

tests/TestPsci/CompletionTest.hs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ import TestUtils (getSupportModuleNames)
1717

1818
completionTests :: Spec
1919
completionTests = context "completionTests" $ do
20-
mns <- runIO $ getSupportModuleNames
21-
mapM_ assertCompletedOk (completionTestData mns)
20+
mns <- runIO getSupportModuleNames
21+
psciState <- runIO getPSCiStateForCompletion
22+
mapM_ (assertCompletedOk psciState) (completionTestData mns)
2223

2324
-- If the cursor is at the right end of the line, with the 1st element of the
2425
-- pair as the text in the line, then pressing tab should offer all the
@@ -87,16 +88,14 @@ completionTestData supportModuleNames =
8788
, ("Control.Monad.Eff.Class.", [])
8889
]
8990

90-
assertCompletedOk :: (String, [String]) -> Spec
91-
assertCompletedOk (line, expecteds) = specify line $ do
92-
results <- runCM (completion' (reverse line, ""))
91+
assertCompletedOk :: PSCiState -> (String, [String]) -> Spec
92+
assertCompletedOk psciState (line, expecteds) = specify line $ do
93+
results <- runCM psciState (completion' (reverse line, ""))
9394
let actuals = formatCompletions results
9495
sort actuals `shouldBe` sort expecteds
9596

96-
runCM :: CompletionM a -> IO a
97-
runCM act = do
98-
psciState <- getPSCiStateForCompletion
99-
evalStateT (liftCompletionM act) psciState
97+
runCM :: PSCiState -> CompletionM a -> IO a
98+
runCM psciState act = evalStateT (liftCompletionM act) psciState
10099

101100
getPSCiStateForCompletion :: IO PSCiState
102101
getPSCiStateForCompletion = do

0 commit comments

Comments
 (0)