Skip to content

Commit 2c7b53c

Browse files
committed
Replace faulty signature test
1 parent 9308ff4 commit 2c7b53c

File tree

1 file changed

+43
-15
lines changed

1 file changed

+43
-15
lines changed

ghcide/test/exe/Main.hs

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,13 +2784,39 @@ removeRedundantConstraintsTests = let
27842784
, " in h"
27852785
]
27862786

2787-
typeSignatureMultipleLines :: T.Text
2788-
typeSignatureMultipleLines = T.unlines $ header <>
2789-
[ "foo :: (Num a, Eq a, Monoid a)"
2790-
, "=> a -> Bool"
2791-
, "foo x = x == 1"
2787+
typeSignatureLined1 = T.unlines $ header <>
2788+
[ "foo :: Eq a =>"
2789+
, " a -> Bool"
2790+
, "foo _ = True"
27922791
]
27932792

2793+
typeSignatureLined2 = T.unlines $ header <>
2794+
[ "foo :: (Eq a, Show a)"
2795+
, " => a -> Bool"
2796+
, "foo _ = True"
2797+
]
2798+
2799+
typeSignatureOneLine = T.unlines $ header <>
2800+
[ "foo :: a -> Bool"
2801+
, "foo _ = True"
2802+
]
2803+
2804+
typeSignatureLined3 = T.unlines $ header <>
2805+
[ "foo :: ( Eq a"
2806+
, " , Show a"
2807+
, " )"
2808+
, " => a -> Bool"
2809+
, "foo x = x == x"
2810+
]
2811+
2812+
typeSignatureLined3' = T.unlines $ header <>
2813+
[ "foo :: ( Eq a"
2814+
, " )"
2815+
, " => a -> Bool"
2816+
, "foo x = x == x"
2817+
]
2818+
2819+
27942820
check :: T.Text -> T.Text -> T.Text -> TestTree
27952821
check actionTitle originalCode expectedCode = testSession (T.unpack actionTitle) $ do
27962822
doc <- createDoc "Testing.hs" "haskell" originalCode
@@ -2801,13 +2827,6 @@ removeRedundantConstraintsTests = let
28012827
modifiedCode <- documentContents doc
28022828
liftIO $ expectedCode @=? modifiedCode
28032829

2804-
checkPeculiarFormatting :: String -> T.Text -> TestTree
2805-
checkPeculiarFormatting title code = testSession title $ do
2806-
doc <- createDoc "Testing.hs" "haskell" code
2807-
_ <- waitForDiagnostics
2808-
actionsOrCommands <- getAllCodeActions doc
2809-
liftIO $ assertBool "Found some actions" (null actionsOrCommands)
2810-
28112830
in testGroup "remove redundant function constraints"
28122831
[ check
28132832
"Remove redundant constraint `Eq a` from the context of the type signature for `foo`"
@@ -2845,9 +2864,18 @@ removeRedundantConstraintsTests = let
28452864
"Remove redundant constraints `(Monoid a, Show a)` from the context of the type signature for `foo`"
28462865
(typeSignatureSpaces $ Just "Monoid a, Show a")
28472866
(typeSignatureSpaces Nothing)
2848-
, checkPeculiarFormatting
2849-
"should do nothing when constraints contain line feeds"
2850-
typeSignatureMultipleLines
2867+
, check
2868+
"Remove redundant constraint `Eq a` from the context of the type signature for `foo`"
2869+
typeSignatureLined1
2870+
typeSignatureOneLine
2871+
, check
2872+
"Remove redundant constraints `(Eq a, Show a)` from the context of the type signature for `foo`"
2873+
typeSignatureLined2
2874+
typeSignatureOneLine
2875+
, check
2876+
"Remove redundant constraint `Show a` from the context of the type signature for `foo`"
2877+
typeSignatureLined3
2878+
typeSignatureLined3'
28512879
]
28522880

28532881
addSigActionTests :: TestTree

0 commit comments

Comments
 (0)