@@ -392,6 +392,7 @@ codeActionTests = testGroup "code actions"
392392 , typeWildCardActionTests
393393 , removeImportTests
394394 , extendImportTests
395+ , addExtensionTests
395396 , fixConstructorImportTests
396397 , importRenameActionTests
397398 , fillTypedHoleTests
@@ -806,6 +807,62 @@ extendImportTests = testGroup "extend import actions"
806807 contentAfterAction <- documentContents docB
807808 liftIO $ expectedContentB @=? contentAfterAction
808809
810+addExtensionTests :: TestTree
811+addExtensionTests = testGroup "add language extension actions"
812+ [ testSession "add NamedFieldPuns language extension" $ template
813+ (T.unlines
814+ [ "module Module where"
815+ , ""
816+ , "data A = A { getA :: Bool }"
817+ , ""
818+ , "f :: A -> Bool"
819+ , "f A { getA } = getA"
820+ ])
821+ (Range (Position 0 0) (Position 0 0))
822+ "Add NamedFieldPuns extension"
823+ (T.unlines
824+ [ "{-# LANGUAGE NamedFieldPuns #-}"
825+ , "module Module where"
826+ , ""
827+ , "data A = A { getA :: Bool }"
828+ , ""
829+ , "f :: A -> Bool"
830+ , "f A { getA } = getA"
831+ ])
832+ , testSession "add RecordWildCards language extension" $ template
833+ (T.unlines
834+ [ "module Module where"
835+ , ""
836+ , "data A = A { getA :: Bool }"
837+ , ""
838+ , "f :: A -> Bool"
839+ , "f A { .. } = getA"
840+ ])
841+ (Range (Position 0 0) (Position 0 0))
842+ "Add RecordWildCards extension"
843+ (T.unlines
844+ [ "{-# LANGUAGE RecordWildCards #-}"
845+ , "module Module where"
846+ , ""
847+ , "data A = A { getA :: Bool }"
848+ , ""
849+ , "f :: A -> Bool"
850+ , "f A { .. } = getA"
851+ ])
852+ ]
853+ where
854+ template initialContent range expectedAction expectedContents = do
855+ doc <- openDoc' "Module.hs" "haskell" initialContent
856+ _ <- waitForDiagnostics
857+ CACodeAction action@CodeAction { _title = actionTitle } : _
858+ <- sortOn (\(CACodeAction CodeAction{_title=x}) -> x) <$>
859+ getCodeActions doc range
860+ liftIO $ expectedAction @=? actionTitle
861+ executeCodeAction action
862+ contentAfterAction <- documentContents doc
863+ liftIO $ expectedContents @=? contentAfterAction
864+
865+
809866insertNewDefinitionTests :: TestTree
810867insertNewDefinitionTests = testGroup "insert new definition actions"
811868 [ testSession "insert new function definition" $ do