Skip to content

Commit 457e2ac

Browse files
committed
Add a test
1 parent 5c869b0 commit 457e2ac

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

haskell-language-server.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ flag rename
106106

107107
flag retrie
108108
description: Enable retrie plugin
109-
default: True
109+
default: False
110110
manual: True
111111

112112
flag tactic

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

+27
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ codeActionTests = testGroup "code actions"
310310
, removeImportTests
311311
, suggestImportClassMethodTests
312312
, suggestImportTests
313+
, suggestAddRecordFieldImportTests
313314
, suggestHideShadowTests
314315
, fixConstructorImportTests
315316
, fixModuleImportTypoTests
@@ -1730,6 +1731,32 @@ suggestImportTests = testGroup "suggest import actions"
17301731
else
17311732
liftIO $ [_title | InR CodeAction{_title} <- actions, _title == newImp ] @?= []
17321733

1734+
suggestAddRecordFieldImportTests :: TestTree
1735+
suggestAddRecordFieldImportTests = testGroup "suggest imports of record fields when using OverloadedRecordDot"
1736+
[ testGroup "The field is suggested when an instance resolution failure occurs"
1737+
[ ignoreFor (BrokenForGHC [GHC810, GHC90, GHC94, GHC96]) "Extension not present <9.2, and the assist is derived from the help message in >=9.4" theTest
1738+
]
1739+
]
1740+
where
1741+
theTest = testSessionWithExtraFiles "hover" def $ \dir -> do
1742+
configureCheckProject False
1743+
let before = T.unlines $ "module A where" : ["import B (Foo)", "getFoo :: Foo -> Int", "getFoo x = x.foo"]
1744+
after = T.unlines $ "module A where" : ["import B (Foo, foo)", "getFoo :: Foo -> Int", "getFoo x = x.foo"]
1745+
cradle = "cradle: {direct: {arguments: [-hide-all-packages, -package, base, -package, text, -package-env, -, A, B]}}"
1746+
liftIO $ writeFileUTF8 (dir </> "hie.yaml") cradle
1747+
liftIO $ writeFileUTF8 (dir </> "B.hs") $ unlines ["module B where", "data Foo = Foo { foo :: Int }"]
1748+
doc <- createDoc "Test.hs" "haskell" before
1749+
waitForProgressDone
1750+
_ <- waitForDiagnostics
1751+
let defLine = fromIntegral $ 1 + 2
1752+
range = Range (Position defLine 0) (Position defLine maxBound)
1753+
actions <- getCodeActions doc range
1754+
action <- liftIO $ pickActionWithTitle "Add foo to the import list of B" actions
1755+
executeCodeAction action
1756+
contentAfterAction <- documentContents doc
1757+
liftIO $ after @=? contentAfterAction
1758+
1759+
17331760
suggestImportDisambiguationTests :: TestTree
17341761
suggestImportDisambiguationTests = testGroup "suggest import disambiguation actions"
17351762
[ testGroup "Hiding strategy works"

0 commit comments

Comments
 (0)