Skip to content

Commit ef0e9fd

Browse files
kdermemergify[bot]
andauthored
Replace faulty signature test (#1792)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent ee7b5a9 commit ef0e9fd

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
@@ -2785,13 +2785,39 @@ removeRedundantConstraintsTests = let
27852785
, " in h"
27862786
]
27872787

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

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

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

28542882
addSigActionTests :: TestTree

0 commit comments

Comments
 (0)