Skip to content

Commit e0c69e4

Browse files
committed
Test remove constraint for signature with spaces
1 parent 1fc2ebf commit e0c69e4

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
@@ -2626,11 +2626,13 @@ removeRedundantConstraintsTests = let
26262626
, "foo x = x == 1"
26272627
]
26282628

2629-
typeSignatureSpaces :: T.Text
2630-
typeSignatureSpaces = T.unlines $ header <>
2631-
[ "foo :: (Num a, Eq a, Monoid a) => a -> Bool"
2632-
, "foo x = x == 1"
2633-
]
2629+
typeSignatureSpaces :: Maybe T.Text -> T.Text
2630+
typeSignatureSpaces mConstraint =
2631+
let constraint = maybe "(Num a, Eq a)" (\c -> "(Num a, Eq a, " <> c <> ")") mConstraint
2632+
in T.unlines $ header <>
2633+
[ "foo :: " <> constraint <> " => a -> Bool"
2634+
, "foo x = x == 1"
2635+
]
26342636

26352637
redundantConstraintsForall :: Maybe T.Text -> T.Text
26362638
redundantConstraintsForall mConstraint =
@@ -2734,9 +2736,10 @@ removeRedundantConstraintsTests = let
27342736
"Remove redundant constraint `Eq a` from the context of the type signature for `foo`"
27352737
(redundantConstraintsForall $ Just "Eq a")
27362738
(redundantConstraintsForall Nothing)
2737-
, checkPeculiarFormatting
2738-
"should do nothing when constraints contain an arbitrary number of spaces"
2739-
typeSignatureSpaces
2739+
, check
2740+
"Remove redundant constraints `(Monoid a, Show a)` from the context of the type signature for `foo`"
2741+
(typeSignatureSpaces $ Just "Monoid a, Show a")
2742+
(typeSignatureSpaces Nothing)
27402743
, checkPeculiarFormatting
27412744
"should do nothing when constraints contain line feeds"
27422745
typeSignatureMultipleLines

0 commit comments

Comments
 (0)