@@ -2784,13 +2784,39 @@ removeRedundantConstraintsTests = let
2784
2784
, " in h"
2785
2785
]
2786
2786
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"
2792
2791
]
2793
2792
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
+
2794
2820
check :: T. Text -> T. Text -> T. Text -> TestTree
2795
2821
check actionTitle originalCode expectedCode = testSession (T. unpack actionTitle) $ do
2796
2822
doc <- createDoc " Testing.hs" " haskell" originalCode
@@ -2845,9 +2871,18 @@ removeRedundantConstraintsTests = let
2845
2871
" Remove redundant constraints `(Monoid a, Show a)` from the context of the type signature for `foo`"
2846
2872
(typeSignatureSpaces $ Just " Monoid a, Show a" )
2847
2873
(typeSignatureSpaces Nothing )
2848
- , checkPeculiarFormatting
2849
- " should do nothing when constraints contain line feeds"
2850
- typeSignatureMultipleLines
2874
+ , check
2875
+ " Remove redundant constraint `Eq a` from the context of the type signature for `foo`"
2876
+ typeSignatureLined1
2877
+ typeSignatureOneLine
2878
+ , check
2879
+ " Remove redundant constraints `(Eq a, Show a)` from the context of the type signature for `foo`"
2880
+ typeSignatureLined2
2881
+ typeSignatureOneLine
2882
+ , check
2883
+ " Remove redundant constraint `Show a` from the context of the type signature for `foo`"
2884
+ typeSignatureLined3
2885
+ typeSignatureLined3'
2851
2886
]
2852
2887
2853
2888
addSigActionTests :: TestTree
0 commit comments