Skip to content

Commit 58e95fc

Browse files
committed
Test remove constraint for signature with spaces
1 parent 998c89f commit 58e95fc

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

ghcide/test/exe/Main.hs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2606,11 +2606,13 @@ removeRedundantConstraintsTests = let
26062606
, "foo x = x == 1"
26072607
]
26082608

2609-
typeSignatureSpaces :: T.Text
2610-
typeSignatureSpaces = T.unlines $ header <>
2611-
[ "foo :: (Num a, Eq a, Monoid a) => a -> Bool"
2612-
, "foo x = x == 1"
2613-
]
2609+
typeSignatureSpaces :: Maybe T.Text -> T.Text
2610+
typeSignatureSpaces mConstraint =
2611+
let constraint = maybe "(Num a, Eq a)" (\c -> "(Num a, Eq a, " <> c <> ")") mConstraint
2612+
in T.unlines $ header <>
2613+
[ "foo :: " <> constraint <> " => a -> Bool"
2614+
, "foo x = x == 1"
2615+
]
26142616

26152617
redundantConstraintsForall :: Maybe T.Text -> T.Text
26162618
redundantConstraintsForall mConstraint =
@@ -2714,9 +2716,10 @@ removeRedundantConstraintsTests = let
27142716
"Remove redundant constraint `Eq a` from the context of the type signature for `foo`"
27152717
(redundantConstraintsForall $ Just "Eq a")
27162718
(redundantConstraintsForall Nothing)
2717-
, checkPeculiarFormatting
2718-
"should do nothing when constraints contain an arbitrary number of spaces"
2719-
typeSignatureSpaces
2719+
, check
2720+
"Remove redundant constraints `(Monoid a, Show a)` from the context of the type signature for `foo`"
2721+
(typeSignatureSpaces $ Just "Monoid a, Show a")
2722+
(typeSignatureSpaces Nothing)
27202723
, checkPeculiarFormatting
27212724
"should do nothing when constraints contain line feeds"
27222725
typeSignatureMultipleLines

0 commit comments

Comments
 (0)