@@ -2785,13 +2785,39 @@ removeRedundantConstraintsTests = let
2785
2785
, " in h"
2786
2786
]
2787
2787
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"
2793
2792
]
2794
2793
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
+
2795
2821
check :: T. Text -> T. Text -> T. Text -> TestTree
2796
2822
check actionTitle originalCode expectedCode = testSession (T. unpack actionTitle) $ do
2797
2823
doc <- createDoc " Testing.hs" " haskell" originalCode
@@ -2802,13 +2828,6 @@ removeRedundantConstraintsTests = let
2802
2828
modifiedCode <- documentContents doc
2803
2829
liftIO $ expectedCode @=? modifiedCode
2804
2830
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
-
2812
2831
in testGroup " remove redundant function constraints"
2813
2832
[ check
2814
2833
" Remove redundant constraint `Eq a` from the context of the type signature for `foo`"
@@ -2846,9 +2865,18 @@ removeRedundantConstraintsTests = let
2846
2865
" Remove redundant constraints `(Monoid a, Show a)` from the context of the type signature for `foo`"
2847
2866
(typeSignatureSpaces $ Just " Monoid a, Show a" )
2848
2867
(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'
2852
2880
]
2853
2881
2854
2882
addSigActionTests :: TestTree
0 commit comments