Skip to content

Commit

Permalink
hls-refactor-plugin: More predictable hole fit for test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
akshaymankar committed Jun 8, 2024
1 parent 0d9bb43 commit 0576add
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plugins/hls-refactor-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2653,16 +2653,16 @@ fillTypedHoleTests = let
, testSession "filling infix type hole uses infix operator" $ do
let mkDoc x = T.unlines
[ "module Testing where"
, "test :: Int -> Int -> Int"
, "test a1 a2 = a1 " <> x <> " a2"
, "test :: Int -> Maybe Int -> Maybe Int"
, "test a ma = (a +) " <> x <> " ma"
]
doc <- createDoc "Test.hs" "haskell" $ mkDoc "`_`"
_ <- waitForDiagnostics
actions <- getCodeActions doc (Range (Position 2 16) (Position 2 19))
chosen <- pickActionWithTitle "replace _ with (+)" actions
chosen <- pickActionWithTitle "replace _ with (<$>)" actions
executeCodeAction chosen
modifiedCode <- documentContents doc
liftIO $ mkDoc "+" @=? modifiedCode
liftIO $ mkDoc "<$>" @=? modifiedCode
]

addInstanceConstraintTests :: TestTree
Expand Down

0 comments on commit 0576add

Please sign in to comment.