Skip to content

Commit 6a8e424

Browse files
committed
hls-refactor-plugin: More predictable hole fit for test
Now that we limit number of hole fits recommended by GHC, the test that hopes to find `+` being recommended for `Int -> Int -> Int` becomes unpredictable because there are too many symbols which match that type and the sorting has little control over which symbols get recommended. There are way fewer matches for `(Int -> Maybe Int) -> Maybe Int -> Maybe Int`, so it makes the test consistently succeed.
1 parent 0d9bb43 commit 6a8e424

File tree

1 file changed

+8
-8
lines changed
  • plugins/hls-refactor-plugin/test

1 file changed

+8
-8
lines changed

plugins/hls-refactor-plugin/test/Main.hs

+8-8
Original file line numberDiff line numberDiff line change
@@ -2640,29 +2640,29 @@ fillTypedHoleTests = let
26402640
, testSession "postfix hole uses postfix notation of infix operator" $ do
26412641
let mkDoc x = T.unlines
26422642
[ "module Testing where"
2643-
, "test :: Int -> Int -> Int"
2644-
, "test a1 a2 = " <> x <> " a1 a2"
2643+
, "test :: Int -> Maybe Int -> Maybe Int"
2644+
, "test a ma = " <> x <> " (a +) ma"
26452645
]
26462646
doc <- createDoc "Test.hs" "haskell" $ mkDoc "_"
26472647
_ <- waitForDiagnostics
26482648
actions <- getCodeActions doc (Range (Position 2 13) (Position 2 14))
2649-
chosen <- pickActionWithTitle "replace _ with (+)" actions
2649+
chosen <- pickActionWithTitle "replace _ with (<$>)" actions
26502650
executeCodeAction chosen
26512651
modifiedCode <- documentContents doc
2652-
liftIO $ mkDoc "(+)" @=? modifiedCode
2652+
liftIO $ mkDoc "(<$>)" @=? modifiedCode
26532653
, testSession "filling infix type hole uses infix operator" $ do
26542654
let mkDoc x = T.unlines
26552655
[ "module Testing where"
2656-
, "test :: Int -> Int -> Int"
2657-
, "test a1 a2 = a1 " <> x <> " a2"
2656+
, "test :: Int -> Maybe Int -> Maybe Int"
2657+
, "test a ma = (a +) " <> x <> " ma"
26582658
]
26592659
doc <- createDoc "Test.hs" "haskell" $ mkDoc "`_`"
26602660
_ <- waitForDiagnostics
26612661
actions <- getCodeActions doc (Range (Position 2 16) (Position 2 19))
2662-
chosen <- pickActionWithTitle "replace _ with (+)" actions
2662+
chosen <- pickActionWithTitle "replace _ with (<$>)" actions
26632663
executeCodeAction chosen
26642664
modifiedCode <- documentContents doc
2665-
liftIO $ mkDoc "+" @=? modifiedCode
2665+
liftIO $ mkDoc "<$>" @=? modifiedCode
26662666
]
26672667

26682668
addInstanceConstraintTests :: TestTree

0 commit comments

Comments
 (0)