From e10843ee02d3859d12f879f71f89098e3f15b02f Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Mon, 31 Jan 2022 15:39:47 +0100 Subject: [PATCH 1/4] test: repro for #2662: extend import list miss separator --- ghcide/test/exe/Main.hs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ghcide/test/exe/Main.hs b/ghcide/test/exe/Main.hs index da2439e3bb..6262cec37d 100644 --- a/ghcide/test/exe/Main.hs +++ b/ghcide/test/exe/Main.hs @@ -1520,6 +1520,20 @@ extendImportTests = testGroup "extend import actions" , "import ModuleA as A (stuffB, (.*))" , "main = print (stuffB .* stuffB)" ]) + , testSession "extend single line import with infix constructor" $ template + [] + ("ModuleB.hs", T.unlines + [ "module ModuleB where" + , "import Data.List.NonEmpty (fromList)" + , "main = case (fromList []) of _ :| _ -> pure ()" + ]) + (Range (Position 2 5) (Position 2 6)) + ["Add NonEmpty((:|)) to the import list of Data.List.NonEmpty"] + (T.unlines + [ "module ModuleB where" + , "import Data.List.NonEmpty (fromList, NonEmpty ((:|)))" + , "main = case (fromList []) of _ :| _ -> pure ()" + ]) , testSession "extend single line import with type" $ template [("ModuleA.hs", T.unlines [ "module ModuleA where" From 016ff739c4be0dcb50e7a8575a4e8fefe3a58d5a Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Mon, 31 Jan 2022 16:19:53 +0100 Subject: [PATCH 2/4] test: Add test for import list extension with prefix ctor --- ghcide/test/exe/Main.hs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ghcide/test/exe/Main.hs b/ghcide/test/exe/Main.hs index 6262cec37d..5c470304cf 100644 --- a/ghcide/test/exe/Main.hs +++ b/ghcide/test/exe/Main.hs @@ -1534,6 +1534,22 @@ extendImportTests = testGroup "extend import actions" , "import Data.List.NonEmpty (fromList, NonEmpty ((:|)))" , "main = case (fromList []) of _ :| _ -> pure ()" ]) + , testSession "extend single line import with prefix constructor" $ template + [] + ("ModuleB.hs", T.unlines + [ "module ModuleB where" + , "import Prelude hiding (Maybe(..))" + , "import Data.Maybe (catMaybes)" + , "x = Just 10" + ]) + (Range (Position 3 5) (Position 2 6)) + ["Add Maybe(Just) to the import list of Data.Maybe"] + (T.unlines + [ "module ModuleB where" + , "import Prelude hiding (Maybe(..))" + , "import Data.Maybe (catMaybes, Maybe (Just))" + , "x = Just 10" + ]) , testSession "extend single line import with type" $ template [("ModuleA.hs", T.unlines [ "module ModuleA where" From c087e64bf62b529fa5ac480c2ffa3a998b92e884 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Mon, 31 Jan 2022 18:28:38 +0100 Subject: [PATCH 3/4] test: Mark failing test explicitly with GHC 9.2 They are failing because of #2662. --- ghcide/test/exe/Main.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ghcide/test/exe/Main.hs b/ghcide/test/exe/Main.hs index 5c470304cf..5fc9fe536f 100644 --- a/ghcide/test/exe/Main.hs +++ b/ghcide/test/exe/Main.hs @@ -1520,7 +1520,7 @@ extendImportTests = testGroup "extend import actions" , "import ModuleA as A (stuffB, (.*))" , "main = print (stuffB .* stuffB)" ]) - , testSession "extend single line import with infix constructor" $ template + , ignoreForGHC92 "missing comma. #2662" $ testSession "extend single line import with infix constructor" $ template [] ("ModuleB.hs", T.unlines [ "module ModuleB where" @@ -1534,7 +1534,7 @@ extendImportTests = testGroup "extend import actions" , "import Data.List.NonEmpty (fromList, NonEmpty ((:|)))" , "main = case (fromList []) of _ :| _ -> pure ()" ]) - , testSession "extend single line import with prefix constructor" $ template + , ignoreForGHC92 "missing comma. #2662" $ testSession "extend single line import with prefix constructor" $ template [] ("ModuleB.hs", T.unlines [ "module ModuleB where" From 6e2cff5075c4e22d660088e970a09a652b482092 Mon Sep 17 00:00:00 2001 From: Guillaume Bouchard Date: Mon, 31 Jan 2022 18:37:14 +0100 Subject: [PATCH 4/4] test: use knownBrokenForGhcVersions instead of ignoreForGHC92 The first one will fail once the test is fixed. --- ghcide/test/exe/Main.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ghcide/test/exe/Main.hs b/ghcide/test/exe/Main.hs index 5fc9fe536f..10c41bd11c 100644 --- a/ghcide/test/exe/Main.hs +++ b/ghcide/test/exe/Main.hs @@ -1520,7 +1520,7 @@ extendImportTests = testGroup "extend import actions" , "import ModuleA as A (stuffB, (.*))" , "main = print (stuffB .* stuffB)" ]) - , ignoreForGHC92 "missing comma. #2662" $ testSession "extend single line import with infix constructor" $ template + , knownBrokenForGhcVersions [GHC92] "missing comma. #2662" $ testSession "extend single line import with infix constructor" $ template [] ("ModuleB.hs", T.unlines [ "module ModuleB where" @@ -1534,7 +1534,7 @@ extendImportTests = testGroup "extend import actions" , "import Data.List.NonEmpty (fromList, NonEmpty ((:|)))" , "main = case (fromList []) of _ :| _ -> pure ()" ]) - , ignoreForGHC92 "missing comma. #2662" $ testSession "extend single line import with prefix constructor" $ template + , knownBrokenForGhcVersions [GHC92] "missing comma. #2662" $ testSession "extend single line import with prefix constructor" $ template [] ("ModuleB.hs", T.unlines [ "module ModuleB where"